Don't reload config in the signal handler
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 6 Oct 2010 13:34:17 +0000 (15:34 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 6 Oct 2010 13:34:17 +0000 (15:34 +0200)
src/main.cpp

index 72f6860..94bc813 100644 (file)
@@ -28,6 +28,7 @@ using namespace std;
 Updater::Ptr updater;
 volatile bool is_online = false;
 volatile bool webcheck_enabled = false;
+volatile bool need_config_reload = false;
 
 /**
  * Checks if a bpdyndnsd process is already running.
@@ -161,8 +162,7 @@ void switch_to_offline(int param)
 void reload_config(int param)
 {
     updater->get_logger()->print_caught_sighup();
-    if ( updater->reload_config() != 0 )
-        exit(-1);
+    need_config_reload = true;
 } /*lint !e715 */
 
 
@@ -330,6 +330,14 @@ int main(int argc, char *argv[])
             updater->get_logger()->print_offline_mode();
         }
 
+        if (need_config_reload)
+        {
+            need_config_reload = false;
+
+            if ( updater->reload_config() != 0 )
+                exit(-1);
+        }
+
         // Snore, snore... don't hog the cpu if we are in daemon_mode.
         if ( updater->get_config()->get_daemon_mode() == 1 )
             sleep(10); /*lint !e534 */