Update main loop to handle detect-less

Update main startup and shutdown loops to work will when detect
is disabled. In this case de_ctx remains NULL.
pull/796/head
Victor Julien 13 years ago
parent 0e08f4b6fc
commit 50f5b246db

@ -2083,41 +2083,47 @@ int main(int argc, char **argv)
FlowInitConfig(FLOW_VERBOSE); FlowInitConfig(FLOW_VERBOSE);
} }
DetectEngineCtx *de_ctx = DetectEngineCtxInit(); DetectEngineCtx *de_ctx = NULL;
if (de_ctx == NULL) { if (!suri.disabled_detect) {
SCLogError(SC_ERR_INITIALIZATION, "initializing detection engine " de_ctx = DetectEngineCtxInit();
"context failed."); if (de_ctx == NULL) {
exit(EXIT_FAILURE); SCLogError(SC_ERR_INITIALIZATION, "initializing detection engine "
} "context failed.");
exit(EXIT_FAILURE);
}
#ifdef __SC_CUDA_SUPPORT__ #ifdef __SC_CUDA_SUPPORT__
if (PatternMatchDefaultMatcher() == MPM_AC_CUDA) if (PatternMatchDefaultMatcher() == MPM_AC_CUDA)
CudaVarsSetDeCtx(de_ctx); CudaVarsSetDeCtx(de_ctx);
#endif /* __SC_CUDA_SUPPORT__ */ #endif /* __SC_CUDA_SUPPORT__ */
SCClassConfLoadClassficationConfigFile(de_ctx); SCClassConfLoadClassficationConfigFile(de_ctx);
SCRConfLoadReferenceConfigFile(de_ctx); SCRConfLoadReferenceConfigFile(de_ctx);
if (ActionInitConfig() < 0) { if (ActionInitConfig() < 0) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
}
} }
if (MagicInit() != 0) if (MagicInit() != 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
SetupDelayedDetect(de_ctx, &suri);
if (!suri.delayed_detect) { if (de_ctx != NULL) {
if (LoadSignatures(de_ctx, &suri) != TM_ECODE_OK) SetupDelayedDetect(de_ctx, &suri);
exit(EXIT_FAILURE);
if (suri.run_mode == RUNMODE_ENGINE_ANALYSIS) { if (!suri.delayed_detect) {
exit(EXIT_SUCCESS); if (LoadSignatures(de_ctx, &suri) != TM_ECODE_OK)
exit(EXIT_FAILURE);
if (suri.run_mode == RUNMODE_ENGINE_ANALYSIS) {
exit(EXIT_SUCCESS);
}
} }
}
/* registering singal handlers we use. We register usr2 here, so that one /* registering singal handlers we use. We register usr2 here, so that one
* can't call it during the first sig load phase */ * can't call it during the first sig load phase */
if (suri.sig_file == NULL && suri.rule_reload == 1 && suri.delayed_detect == 0) if (suri.sig_file == NULL && suri.rule_reload == 1 && suri.delayed_detect == 0)
UtilSignalHandlerSetup(SIGUSR2, SignalHandlerSigusr2); UtilSignalHandlerSetup(SIGUSR2, SignalHandlerSigusr2);
}
SCAsn1LoadConfig(); SCAsn1LoadConfig();
@ -2183,7 +2189,7 @@ int main(int argc, char **argv)
/* Un-pause all the paused threads */ /* Un-pause all the paused threads */
TmThreadContinueThreads(); TmThreadContinueThreads();
if (suri.delayed_detect) { if (de_ctx != NULL && suri.delayed_detect) {
if (LoadSignatures(de_ctx, &suri) != TM_ECODE_OK) if (LoadSignatures(de_ctx, &suri) != TM_ECODE_OK)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
de_ctx->delayed_detect_initialized = 1; de_ctx->delayed_detect_initialized = 1;
@ -2257,7 +2263,7 @@ int main(int argc, char **argv)
} }
DetectEngineCtx *global_de_ctx = DetectEngineGetGlobalDeCtx(); DetectEngineCtx *global_de_ctx = DetectEngineGetGlobalDeCtx();
if (suri.run_mode != RUNMODE_UNIX_SOCKET) { if (suri.run_mode != RUNMODE_UNIX_SOCKET && de_ctx != NULL) {
BUG_ON(global_de_ctx == NULL); BUG_ON(global_de_ctx == NULL);
} }

Loading…
Cancel
Save