From: Victor Julien Date: Thu, 31 Oct 2024 16:41:26 +0000 (+0100) Subject: unix/socket: cleanup start up logic X-Git-Tag: suricata-8.0.0-beta1~599 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aab50e8ad0171680d30725af8f35cf7ec59a02bf;p=thirdparty%2Fsuricata.git unix/socket: cleanup start up logic No longer init then deinit part of the engine at startup of the unix socket mode. --- diff --git a/src/suricata.c b/src/suricata.c index 6a01b55dd3..12224e64b6 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -2210,7 +2210,6 @@ static int InitSignalHandler(SCInstance *suri) * Will be run once per pcap in unix-socket mode */ void PreRunInit(const int runmode) { - HttpRangeContainersInit(); if (runmode == RUNMODE_UNIX_SOCKET) return; @@ -2233,32 +2232,27 @@ void PreRunInit(const int runmode) AppLayerParserPostStreamSetup(); AppLayerRegisterGlobalCounters(); OutputFilestoreRegisterGlobalCounters(); + HttpRangeContainersInit(); } /* tasks we need to run before packets start flowing, * but after we dropped privs */ void PreRunPostPrivsDropInit(const int runmode) { - StatsSetupPostConfigPreOutput(); - RunModeInitializeOutputs(); - DatasetsInit(); - if (runmode == RUNMODE_UNIX_SOCKET) { - /* As the above did some necessary startup initialization, it - * also setup some outputs where only one is allowed, so - * deinitialize to the state that unix-mode does after every - * pcap. */ - PostRunDeinit(RUNMODE_PCAP_FILE, NULL); return; } + StatsSetupPostConfigPreOutput(); + RunModeInitializeOutputs(); + DatasetsInit(); StatsSetupPostConfigPostOutput(); } -/* clean up / shutdown code for both the main modes and for - * unix socket mode. +/** \brief clean up / shutdown code for packet modes * - * Will be run once per pcap in unix-socket mode */ + * Shuts down packet modes, so regular packet runmodes and the + * per pcap mode in the unix socket. */ void PostRunDeinit(const int runmode, struct timeval *start_time) { if (runmode == RUNMODE_UNIX_SOCKET) @@ -2968,12 +2962,11 @@ void SuricataInit(void) prerun_snap = SystemHugepageSnapshotCreate(); SCSetStartTime(&suricata); - RunModeDispatch(suricata.run_mode, suricata.runmode_custom_mode, - suricata.capture_plugin_name, suricata.capture_plugin_args); if (suricata.run_mode != RUNMODE_UNIX_SOCKET) { UnixManagerThreadSpawnNonRunmode(suricata.unix_socket_enabled); } - + RunModeDispatch(suricata.run_mode, suricata.runmode_custom_mode, suricata.capture_plugin_name, + suricata.capture_plugin_args); return; out: