Gracefully exit through the main thread.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 15 Jan 2011 21:19:11 +0000 (22:19 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 15 Jan 2011 21:19:11 +0000 (22:19 +0100)
src/control.c
src/net.c
src/process.c

index 73d79166700b0d631e01d0df7a49d61bfe941cfc..2e6be57679f0fbb5799ac25535ee3a423abe57bb 100644 (file)
@@ -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:
index 3eec9a647b5e3b2e77116323b05637b5dcdab8cf..e52363e4a685f8586d6652639e452e9867df6e1c 100644 (file)
--- 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);
index e6b108f5ab10e68b9c2d6acf61daf7e869dff6dc..d88ff970f457ea66ae26d35a95713025e659937c 100644 (file)
@@ -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);