From 43b0bc8c8e343aadad2b8c4bd96fe74b8a5fa3df Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 24 May 2017 21:30:48 +0200 Subject: [PATCH] unix socket: improve runmode handling 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 | 13 +++++++++---- src/suricata.c | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/runmode-unix-socket.c b/src/runmode-unix-socket.c index af80816e53..79eb787c8e 100644 --- a/src/runmode-unix-socket.c +++ b/src/runmode-unix-socket.c @@ -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; diff --git a/src/suricata.c b/src/suricata.c index 62a2cd9dde..6604601bf3 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -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 -- 2.47.2