]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-engine: remove DONE state
authorGiuseppe Longo <glongo@stamus-networks.com>
Wed, 4 May 2016 15:13:39 +0000 (17:13 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 11 Dec 2017 08:16:45 +0000 (09:16 +0100)
Remove the DONE state to fix a problem with state not being
changed correctly when multiple reload were done. As DONE was
not really useful, we can remove it.

src/detect-engine.c
src/detect-engine.h
src/suricata.c
src/unix-manager.c

index 3bd758b0abfe6010bf509d9e3d2c63e15ae74c7c..87f944e77dab3b4b40a98bbdb9907ee1eb64bb28 100644 (file)
@@ -626,7 +626,6 @@ void DetectBufferTypeFinalizeRegistration(void)
 enum DetectEngineSyncState {
     IDLE,   /**< ready to start a reload */
     RELOAD, /**< command main thread to do the reload */
-    DONE,   /**< main thread telling us reload is done */
 };
 
 
@@ -664,21 +663,20 @@ int DetectEngineReloadIsStart(void)
 }
 
 /* main thread sets done when it's done */
-void DetectEngineReloadSetDone(void)
+void DetectEngineReloadSetIdle(void)
 {
     SCMutexLock(&detect_sync.m);
-    detect_sync.state = DONE;
+    detect_sync.state = IDLE;
     SCMutexUnlock(&detect_sync.m);
 }
 
 /* caller loops this until it returns 1 */
-int DetectEngineReloadIsDone(void)
+int DetectEngineReloadIsIdle(void)
 {
     int r = 0;
     SCMutexLock(&detect_sync.m);
-    if (detect_sync.state == DONE) {
+    if (detect_sync.state == IDLE) {
         r = 1;
-        detect_sync.state = IDLE;
     }
     SCMutexUnlock(&detect_sync.m);
     return r;
index 447042101402a649fd808433adf50e8f22320586..bd738550d5aace75903408e56cd8f09fa1c05d16 100644 (file)
@@ -83,8 +83,8 @@ int DetectEngineMultiTenantSetup(void);
 
 int DetectEngineReloadStart(void);
 int DetectEngineReloadIsStart(void);
-void DetectEngineReloadSetDone(void);
-int DetectEngineReloadIsDone(void);
+void DetectEngineReloadSetIdle(void);
+int DetectEngineReloadIsIdle(void);
 
 int DetectEngineLoadTenantBlocking(uint32_t tenant_id, const char *yaml);
 int DetectEngineReloadTenantBlocking(uint32_t tenant_id, const char *yaml, int reload_cnt);
index d3fea4bab6d527d2d95fbd026c5bd1cee9a7989d..d978622a2d1ae87b64de193a16004daa3c0caae0 100644 (file)
@@ -2779,7 +2779,7 @@ static void SuricataMainLoop(SCInstance *suri)
                 if (!(DetectEngineReloadIsStart())) {
                     DetectEngineReloadStart();
                     DetectEngineReload(suri);
-                    DetectEngineReloadSetDone();
+                    DetectEngineReloadSetIdle();
                     sigusr2_count--;
                 }
             }
@@ -2788,10 +2788,10 @@ static void SuricataMainLoop(SCInstance *suri)
             if (suri->sig_file != NULL) {
                 SCLogWarning(SC_ERR_LIVE_RULE_SWAP, "Live rule reload not "
                         "possible if -s or -S option used at runtime.");
-                DetectEngineReloadSetDone();
+                DetectEngineReloadSetIdle();
             } else {
                 DetectEngineReload(suri);
-                DetectEngineReloadSetDone();
+                DetectEngineReloadSetIdle();
             }
         }
 
index b07417b4d8bc6a6d625a0e5d64303e0c8754d59a..865617d0a0d80821a38c8a3e58515b41aace4a82 100644 (file)
@@ -659,7 +659,7 @@ static TmEcode UnixManagerReloadRules(json_t *cmd, json_t *server_msg, void *dat
     SCEnter();
     DetectEngineReloadStart();
 
-    while (DetectEngineReloadIsDone() == 0)
+    while (!DetectEngineReloadIsIdle())
         usleep(100);
 
     json_object_set_new(server_msg, "message", json_string("done"));