From 597099c664c9c00f485b088b5f29161b343fea0f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 12 May 2014 04:08:12 +0200 Subject: m fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-server/mds-server.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/mds-server') diff --git a/src/mds-server/mds-server.c b/src/mds-server/mds-server.c index 9879579..3bf3cd7 100644 --- a/src/mds-server/mds-server.c +++ b/src/mds-server/mds-server.c @@ -211,7 +211,10 @@ int main(int argc_, char** argv_) } unparsed_args[unparsed_args_ptr] = NULL; if (reexec) - is_respawn = 1; + { + is_respawn = 1; + eprint("re-exec:ing done."); + } /* Check that manditory arguments have been specified. */ @@ -248,7 +251,6 @@ int main(int argc_, char** argv_) } } - #define __free(I) \ if (I <= 0) fd_table_destroy(&client_map, NULL, NULL); \ if (I <= 1) linked_list_destroy(&client_list); \ @@ -329,19 +331,19 @@ int main(int argc_, char** argv_) pid_t pid = getpid(); int reexec_fd, r; char shm_path[NAME_MAX + 1]; + + /* Acquire access to marshalled data. */ xsnprintf(shm_path, SHM_PATH_PATTERN, (unsigned long int)pid); - reexec_fd = shm_open(shm_path, O_RDWR | O_CREAT | O_EXCL, S_IRWXU); + reexec_fd = shm_open(shm_path, O_RDONLY, S_IRWXU); if (reexec_fd < 0) { perror(*argv); - r = -1; - } - else - { - r = unmarshal_server(reexec_fd); - close(reexec_fd); - shm_unlink(shm_path); + abort(); /* Critical. */ } + /* Unmarshal state. */ + r = unmarshal_server(reexec_fd); + close(reexec_fd); + shm_unlink(shm_path); if (r < 0) { /* Close all files (hopefully sockets) we do not know what they are. */ @@ -447,11 +449,11 @@ int main(int argc_, char** argv_) client_t* client = (client_t*)(void*)(client_list.values[node]); client_destroy(client); } + fd_table_destroy(&client_map, NULL, NULL); + linked_list_destroy(&client_list); /* Re-exec the server. */ reexec_server(argc, argv, reexec); - fd_table_destroy(&client_map, NULL, NULL); - linked_list_destroy(&client_list); reexec_fail: perror(*argv); @@ -1526,6 +1528,8 @@ void sigusr1_trap(int signo) reexecing = 1; current_thread = pthread_self(); + eprint("re-exec:ing queue."); + if (pthread_equal(current_thread, master_thread) == 0) pthread_kill(master_thread, signo); -- cgit v1.2.3-70-g09d2