detect reload: allow master update during reload

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.
pull/1389/head
Victor Julien 11 years ago
parent b1c54a8673
commit 55e7370fc5

@ -1308,7 +1308,7 @@ static TmEcode DetectEngineThreadCtxInitForLiveRuleSwap(ThreadVars *tv, void *in
memset(det_ctx, 0, sizeof(DetectEngineThreadCtx)); memset(det_ctx, 0, sizeof(DetectEngineThreadCtx));
det_ctx->tv = tv; det_ctx->tv = tv;
det_ctx->de_ctx = DetectEngineGetCurrent(); det_ctx->de_ctx = DetectEngineReference(initdata);
if (det_ctx->de_ctx == NULL) { if (det_ctx->de_ctx == NULL) {
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }
@ -1527,6 +1527,14 @@ DetectEngineCtx *DetectEngineGetCurrent(void)
return master->list; 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) void DetectEngineDeReference(DetectEngineCtx **de_ctx)
{ {
BUG_ON((*de_ctx)->ref_cnt == 0); BUG_ON((*de_ctx)->ref_cnt == 0);

@ -72,6 +72,7 @@ int DetectEngineAddToMaster(DetectEngineCtx *de_ctx);
DetectEngineCtx *DetectEngineGetCurrent(void); DetectEngineCtx *DetectEngineGetCurrent(void);
void DetectEnginePruneFreeList(void); void DetectEnginePruneFreeList(void);
int DetectEngineMoveToFreeList(DetectEngineCtx *de_ctx); int DetectEngineMoveToFreeList(DetectEngineCtx *de_ctx);
DetectEngineCtx *DetectEngineReference(DetectEngineCtx *);
void DetectEngineDeReference(DetectEngineCtx **de_ctx); void DetectEngineDeReference(DetectEngineCtx **de_ctx);
int DetectEngineReload(void); int DetectEngineReload(void);
int DetectEngineEnabled(void); int DetectEngineEnabled(void);

Loading…
Cancel
Save