From 0acbdba62ea6798427366a12aaeebccbf7226b26 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 15 Jan 2011 22:19:11 +0100 Subject: [PATCH] Gracefully exit through the main thread. --- src/control.c | 2 +- src/net.c | 7 +++---- src/process.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/control.c b/src/control.c index 73d7916..2e6be57 100644 --- a/src/control.c +++ b/src/control.c @@ -54,7 +54,7 @@ bool control_h(connection_t *c, char *request) { switch (type) { case REQ_STOP: - abort(); + running = false; return control_ok(c, REQ_STOP); case REQ_DUMP_NODES: diff --git a/src/net.c b/src/net.c index 3eec9a6..e52363e 100644 --- a/src/net.c +++ b/src/net.c @@ -199,7 +199,7 @@ static void timeout_handler(void *arg) { if(rand() % 3 == 0) { logger(LOG_ERR, "Shutting down, check configuration of all nodes for duplicate Names!"); - abort(); + running = false; return; } @@ -259,7 +259,7 @@ int reload_configuration(void) { if(!read_server_config()) { logger(LOG_ERR, "Unable to reread configuration file, exitting."); - abort(); + running = false; return EINVAL; } @@ -352,8 +352,7 @@ int main_loop(void) { event_add(&timeout_event); - - while(true) { + while(running) { mutex_unlock(&mutex); usleep(1000000); mutex_lock(&mutex); diff --git a/src/process.c b/src/process.c index e6b108f..d88ff97 100644 --- a/src/process.c +++ b/src/process.c @@ -166,7 +166,7 @@ DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) { return ERROR_CALL_NOT_IMPLEMENTED; } - abort(); + running = false; status.dwWaitHint = 30000; status.dwCurrentState = SERVICE_STOP_PENDING; SetServiceStatus(statushandle, &status); -- 2.25.1