]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow-manager: move time check after RUNNNING state change
authorLukas Sismis <lsismis@oisf.net>
Sun, 27 Apr 2025 10:56:02 +0000 (12:56 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 21 May 2025 07:37:24 +0000 (09:37 +0200)
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: 7568

src/flow-manager.c

index 680c080fcf929a4d566406cbfd28196fbfa3be48..a91b7906a3aa63a8fdf74adc421f9c73b80af953 100644 (file)
@@ -828,13 +828,6 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
     bool prev_emerg = false;
     uint32_t other_last_sec = 0; /**< last sec stamp when defrag etc ran */
 
-    /* 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);
@@ -844,6 +837,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);
+    }
     bool run = TmThreadsWaitForUnpause(th_v);
 
     while (run) {