]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-reload: 0 detect threads is no error
authorVictor Julien <victor@inliniac.net>
Mon, 16 Mar 2015 09:53:56 +0000 (10:53 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 19 Mar 2015 17:02:19 +0000 (18:02 +0100)
The reload code would consider 0 detect threads to be an error,
but it's not in case of unix socket mode.

src/detect-engine.c

index f643594cf154d445651c489f42c7a1c97cc76ce7..4bf33eaefaddd2a9fbf5d7260e854a8c6e7e896c 100644 (file)
@@ -509,6 +509,19 @@ int DetectEngineReloadIsDone(void)
     return r;
 }
 
+/** \internal
+ *  \brief Update detect threads with new detect engine
+ *
+ *  Atomically update each detect thread with a new thread context
+ *  that is associated to the new detection engine(s).
+ *
+ *  If called in unix socket mode, it's possible that we don't have
+ *  detect threads yet.
+ *
+ *  \retval -1 error
+ *  \retval 0 no detection threads
+ *  \retval 1 successful reload
+ */
 static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
 {
     SCEnter();
@@ -517,8 +530,6 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
     int no_of_detect_tvs = 0;
     ThreadVars *tv = NULL;
 
-    SCLogNotice("rule reload starting");
-
     /* count detect threads in use */
     SCMutexLock(&tv_root_lock);
     tv = tv_root[TVT_PPT];
@@ -546,10 +557,13 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
     }
     SCMutexUnlock(&tv_root_lock);
 
+    /* can be zero in unix socket mode */
     if (no_of_detect_tvs == 0) {
-        return -1;
+        return 0;
     }
 
+    SCLogNotice("rule reload starting");
+
     /* prepare swap structures */
     DetectEngineThreadCtx *old_det_ctx[no_of_detect_tvs];
     DetectEngineThreadCtx *new_det_ctx[no_of_detect_tvs];
@@ -700,7 +714,7 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
     SRepReloadComplete();
 
     SCLogNotice("rule reload complete");
-    return 0;
+    return 1;
 
  error:
     for (i = 0; i < no_of_detect_tvs; i++) {