]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: move reload into main loop
authorVictor Julien <victor@inliniac.net>
Mon, 19 Jan 2015 21:09:59 +0000 (22:09 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 19 Mar 2015 16:52:32 +0000 (17:52 +0100)
Use new DetectEngineReload() function. It's called from the main loop
instead of it being spawned into it's own temporary thread. This greatly
simplifies the signal handling.

An added advantage is that this seems to improve the memory usage.

Related to bug #1358

src/suricata.c

index 839c08adae5eeee5e794bf79b9fbcb706fd22383..c35fb20fa3c649333fdce8315108e84528ebfaec 100644 (file)
 volatile sig_atomic_t sigint_count = 0;
 volatile sig_atomic_t sighup_count = 0;
 volatile sig_atomic_t sigterm_count = 0;
+volatile sig_atomic_t sigusr2_count = 0;
 
 /*
  * Flag to indicate if the engine is at the initialization
@@ -316,6 +317,7 @@ void SignalHandlerSigusr2Idle(int sig)
 
 void SignalHandlerSigusr2(int sig)
 {
+#if 0
     if (run_mode == RUNMODE_UNKNOWN || run_mode == RUNMODE_UNITTEST) {
         SCLogInfo("Ruleset load signal USR2 triggered for wrong runmode");
         return;
@@ -331,6 +333,8 @@ void SignalHandlerSigusr2(int sig)
     DetectEngineSpawnLiveRuleSwapMgmtThread();
 
     return;
+#endif
+    sigusr2_count = 1;
 }
 
 /**
@@ -2442,6 +2446,10 @@ int main(int argc, char **argv)
             OutputNotifyFileRotation();
             sighup_count--;
         }
+        if (sigusr2_count > 0) {
+            DetectEngineReload();
+            sigusr2_count--;
+        }
 
         usleep(10* 1000);
     }