]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
runmodes: for test runmodes, clean up properly
authorVictor Julien <victor@inliniac.net>
Mon, 29 Apr 2019 08:47:50 +0000 (10:47 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 29 Apr 2019 13:23:48 +0000 (15:23 +0200)
For conf test and engine analysis, clean up memory correctly.

This helps valgrind tests for leaks.

src/suricata.c

index c16511451218e8d91596140a58c16b3ff6616742..52e9c5bbfb04060614bf0c57ffb9270c44381627 100644 (file)
@@ -2571,9 +2571,6 @@ static void PostConfLoadedDetectSetup(SCInstance *suri)
         if (de_ctx->type == DETECT_ENGINE_TYPE_NORMAL) {
             if (LoadSignatures(de_ctx, suri) != TM_ECODE_OK)
                 exit(EXIT_FAILURE);
-            if (suri->run_mode == RUNMODE_ENGINE_ANALYSIS) {
-                exit(EXIT_SUCCESS);
-            }
         }
 
         gettimeofday(&de_ctx->last_reload, NULL);
@@ -2985,13 +2982,11 @@ int main(int argc, char **argv)
     PreRunPostPrivsDropInit(suricata.run_mode);
 
     PostConfLoadedDetectSetup(&suricata);
-
-    if (suricata.run_mode == RUNMODE_CONF_TEST){
+    if (suricata.run_mode == RUNMODE_ENGINE_ANALYSIS) {
+        goto out;
+    } else if (suricata.run_mode == RUNMODE_CONF_TEST){
         SCLogNotice("Configuration provided was successfully loaded. Exiting.");
-#ifdef HAVE_MAGIC
-        MagicDeinit();
-#endif
-        exit(EXIT_SUCCESS);
+        goto out;
     }
 
     SCSetStartTime(&suricata);
@@ -3033,6 +3028,7 @@ int main(int argc, char **argv)
     /* kill remaining threads */
     TmThreadKillThreads();
 
+out:
     GlobalsDestroy(&suricata);
 
     exit(EXIT_SUCCESS);