]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect reload: allow master update during reload
authorVictor Julien <victor@inliniac.net>
Tue, 27 Jan 2015 10:30:08 +0000 (11:30 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 19 Mar 2015 16:52:32 +0000 (17:52 +0100)
Add DetectEngineReference, which takes a reference to a detect engine,
and make DetectEngineThreadCtxInitForLiveRuleSwap use it. This way
reload will not depend on master staying the same. This allows master
to be updated in between w/o affecting the reload that is in progress.

src/detect-engine.c
src/detect-engine.h

index 93aab657807c13e4c8e90819f62bf8cf5f40a74e..f9785c7c982b89a51826fde7612a1f12f369cb86 100644 (file)
@@ -1308,7 +1308,7 @@ static TmEcode DetectEngineThreadCtxInitForLiveRuleSwap(ThreadVars *tv, void *in
     memset(det_ctx, 0, sizeof(DetectEngineThreadCtx));
 
     det_ctx->tv = tv;
-    det_ctx->de_ctx = DetectEngineGetCurrent();
+    det_ctx->de_ctx = DetectEngineReference(initdata);
     if (det_ctx->de_ctx == NULL) {
         return TM_ECODE_FAILED;
     }
@@ -1527,6 +1527,14 @@ DetectEngineCtx *DetectEngineGetCurrent(void)
     return master->list;
 }
 
+DetectEngineCtx *DetectEngineReference(DetectEngineCtx *de_ctx)
+{
+    if (de_ctx == NULL)
+        return NULL;
+    de_ctx->ref_cnt++;
+    return de_ctx;
+}
+
 void DetectEngineDeReference(DetectEngineCtx **de_ctx)
 {
     BUG_ON((*de_ctx)->ref_cnt == 0);
index af580751341f425629430f40149f9cf5d22d3589..b95f509ebb254355df33b40678b02f7f0191d60a 100644 (file)
@@ -72,6 +72,7 @@ int DetectEngineAddToMaster(DetectEngineCtx *de_ctx);
 DetectEngineCtx *DetectEngineGetCurrent(void);
 void DetectEnginePruneFreeList(void);
 int DetectEngineMoveToFreeList(DetectEngineCtx *de_ctx);
+DetectEngineCtx *DetectEngineReference(DetectEngineCtx *);
 void DetectEngineDeReference(DetectEngineCtx **de_ctx);
 int DetectEngineReload(void);
 int DetectEngineEnabled(void);