aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile2
-rw-r--r--src/libmdsserver/util.c2
-rw-r--r--src/mds-server/mds-server.c28
-rw-r--r--src/mds.c2
4 files changed, 19 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 62a2c98..1052984 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@ LDS = -pthread -Lbin -lmdsserver -lrt
DEBUG_FLAGS =
ifeq ($(DEBUG),y)
DEBUG_FLAGS += -D'DEBUG'
-DEBUG_FLAGS += -D'LIBEXECDIR="$(shell pwd)/bin/"'
+DEBUG_FLAGS += -D'LIBEXECDIR="$(shell pwd)/bin"'
endif
# Options for the C compiler.
diff --git a/src/libmdsserver/util.c b/src/libmdsserver/util.c
index a3a1867..07f4bfa 100644
--- a/src/libmdsserver/util.c
+++ b/src/libmdsserver/util.c
@@ -72,7 +72,7 @@ void reexec_server(int argc, char** argv, int reexeced)
{
*reexec_args_++ = *argv;
*reexec_args_ = strdup("--re-exec");
- if (*reexec_args_)
+ if (*reexec_args_ == NULL)
return;
for (i = 1; i < argc; i++)
reexec_args_[i] = argv[i];
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);
diff --git a/src/mds.c b/src/mds.c
index 74cc994..042cb48 100644
--- a/src/mds.c
+++ b/src/mds.c
@@ -350,7 +350,7 @@ int spawn_and_respawn_server(int fd)
}
/* Respawn if the server did not die too fast. */
- if (time_end.tv_sec - time_start.tv_sec < RESPAWN_TIME_LIMIT_SECONDS)
+ if (time_end.tv_sec - time_start.tv_sec >= RESPAWN_TIME_LIMIT_SECONDS)
eprintf("%s died abnormally, respawning.", master_server);
else
{