]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
unix socket: improve runmode handling 2729/head
authorVictor Julien <victor@inliniac.net>
Wed, 24 May 2017 19:30:48 +0000 (21:30 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 31 May 2017 09:32:35 +0000 (11:32 +0200)
Improve output of unix mode in --list-runmodes

Honor the runmode commandline setting. Supported are 'single'
and 'autofp', with the latter still the default.

src/runmode-unix-socket.c
src/suricata.c

index af80816e5352f664c2a69a1358e41da10a6d6a2d..79eb787c8e2b3fdc9180c7457b3ec4dff50567dc 100644 (file)
@@ -67,7 +67,7 @@ const char *RunModeUnixSocketGetDefaultMode(void)
 
 #ifdef BUILD_UNIX_SOCKET
 
-static int RunModeUnixSocketSingle(void);
+static int RunModeUnixSocketMaster(void);
 static int unix_manager_file_task_running = 0;
 static int unix_manager_file_task_failed = 0;
 
@@ -351,6 +351,7 @@ static TmEcode UnixSocketPcapFilesCheck(void *data)
     RunModeDispatch(RUNMODE_PCAP_FILE, NULL);
 
     /* Un-pause all the paused threads */
+    TmThreadWaitOnThreadInit();
     TmThreadContinueThreads();
     return TM_ECODE_OK;
 }
@@ -359,10 +360,14 @@ static TmEcode UnixSocketPcapFilesCheck(void *data)
 void RunModeUnixSocketRegister(void)
 {
 #ifdef BUILD_UNIX_SOCKET
+    /* a bit of a hack, but register twice to --list-runmodes shows both */
     RunModeRegisterNewRunMode(RUNMODE_UNIX_SOCKET, "single",
                               "Unix socket mode",
-                              RunModeUnixSocketSingle);
-    default_mode = "single";
+                              RunModeUnixSocketMaster);
+    RunModeRegisterNewRunMode(RUNMODE_UNIX_SOCKET, "autofp",
+                              "Unix socket mode",
+                              RunModeUnixSocketMaster);
+    default_mode = "autofp";
 #endif
     return;
 }
@@ -1012,7 +1017,7 @@ TmEcode UnixSocketHostbitList(json_t *cmd, json_t* answer, void *data_unused)
 /**
  * \brief Single thread version of the Pcap file processing.
  */
-static int RunModeUnixSocketSingle(void)
+static int RunModeUnixSocketMaster(void)
 {
     if (UnixManagerInit() != 0)
         return 1;
index 62a2cd9ddeeb8ed69050e68a8e01f15435738391..6604601bf300ee3ec8047bff943c8a53a25f6111 100644 (file)
@@ -2584,6 +2584,10 @@ static int PostConfLoadedSetup(SCInstance *suri)
             break;
     }
 
+    if (suri->runmode_custom_mode) {
+        ConfSet("runmode", suri->runmode_custom_mode);
+    }
+
     AppLayerSetup();
 
     /* Check for the existance of the default logging directory which we pick