From: Victor Julien Date: Mon, 16 Mar 2015 09:53:56 +0000 (+0100) Subject: detect-reload: 0 detect threads is no error X-Git-Tag: suricata-2.1beta4~112 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=724c7044e19e0e1624982720653eaf6b8c95606f;p=thirdparty%2Fsuricata.git detect-reload: 0 detect threads is no error The reload code would consider 0 detect threads to be an error, but it's not in case of unix socket mode. --- diff --git a/src/detect-engine.c b/src/detect-engine.c index f643594cf1..4bf33eaefa 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -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++) {