From: Guus Sliepen Date: Sat, 15 Jan 2011 21:19:11 +0000 (+0100) Subject: Gracefully exit through the main thread. X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=0acbdba62ea6798427366a12aaeebccbf7226b26;p=tinc Gracefully exit through the main thread. --- diff --git a/src/control.c b/src/control.c index 73d79166..2e6be576 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 3eec9a64..e52363e4 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 e6b108f5..d88ff970 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);