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.
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;
}
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);
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);