fixed crash management
authorpk910 <philipp@zoelle1.de>
Thu, 16 Feb 2012 18:25:33 +0000 (19:25 +0100)
committerpk910 <philipp@zoelle1.de>
Thu, 16 Feb 2012 19:18:56 +0000 (20:18 +0100)
src/main.c
src/signal.c

index c5413d9ef37f12bb82ea06d083d618d585e5e5a6..f567e93f3e92ec5eaf0cd4b1e54caa1bea401cca 100644 (file)
@@ -116,11 +116,13 @@ void * thread_main(void *arg) {
         socket_wait = time(0) + SOCKET_SELECT_TIME;
         do {
             if(!socket_loop(SOCKET_SELECT_TIME)) {
+                if(!running) break;
                 putlog(LOGLEVEL_ERROR, "No more active Bots... shutting down.\n");
                 cleanup();
                 exit(0);
             }
         } while(time(0) < socket_wait);
+        if(!running) break;
         clearTempUsers();
         destroyEvents();
         mysql_free();
@@ -147,6 +149,7 @@ int getCurrentThreadID() {
 #endif
 
 void exit_daemon() {
+    running = 0;
     if(daemonized) {
         remove(PID_FILE);
     }
index 8886e6f471eaa11f360b4b51bbe0b42fbf9e03c8..1eb2383e8982069f2955e1f705abc47c9743cf0c 100644 (file)
@@ -90,9 +90,10 @@ static void sigcrash(int signum) {
     }
     putlog(LOGLEVEL_INFO, "hard shutdown...\n");
     exit_daemon();
-    usleep(1000000);
+    usleep(2000000);
     //hard restart
     restart_process();
+    exit(0);
 }
 
 static void sigexit(int signum) {