From: Lukas Sismis Date: Sun, 27 Apr 2025 10:56:02 +0000 (+0200) Subject: flow-manager: move time check after RUNNNING state change X-Git-Tag: suricata-7.0.11~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2764695596c0f4358c586ee6da3dddfed42c8850;p=thirdparty%2Fsuricata.git flow-manager: move time check after RUNNNING state change When running in pcap-file mode and with a continous directory reading, the provided directory can be empty. By having no packets and being in offline mode, the initial packet timestamp is never set. However, Flow Manager waited until the timestamp was set to proceed with transferring its state to "RUNNING". Other pcap-related threads (RX / workers) are set in RUNNING state while waiting for the PCAP to appear in the directory. As a result, the main Suricata-Main thread timed out after the default 60 seconds budget for threads to turn from INIT_DONE to RUNNING state. Ticket: 7661 (cherry picked from commit 58df9703913201c8eecaea5c3b9bd6fb79eb7128) --- diff --git a/src/flow-manager.c b/src/flow-manager.c index f58bcf41ff..a595300f00 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -808,13 +808,6 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data) uint32_t other_last_sec = 0; /**< last sec stamp when defrag etc ran */ SCTime_t ts; - /* don't start our activities until time is setup */ - while (!TimeModeIsReady()) { - if (suricata_ctl_flags != 0) - return TM_ECODE_OK; - usleep(10); - } - uint32_t mp = MemcapsGetPressure() * 100; if (ftd->instance == 0) { StatsSetUI64(th_v, ftd->cnt.memcap_pressure, mp); @@ -824,6 +817,12 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data) StatsSetUI64(th_v, ftd->cnt.flow_mgr_rows_sec, rows_sec); TmThreadsSetFlag(th_v, THV_RUNNING); + /* don't start our activities until time is setup */ + while (!TimeModeIsReady()) { + if (suricata_ctl_flags != 0) + return TM_ECODE_OK; + usleep(10); + } while (1) {