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 11 years ago
parent 0e08f4b6fc
commit 50f5b246db

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

Loading…
Cancel
Save