]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
time: only consider packet threads
authorVictor Julien <vjulien@oisf.net>
Mon, 20 May 2024 20:09:06 +0000 (22:09 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 23 May 2024 15:27:38 +0000 (17:27 +0200)
In offline mode, a timestamp is kept per thread, and the lowest
timestamp of the active threads is used. This was also considering the
non-packet threads, which could lead to the used timestamp being further
behind that needed. This would happen at the start of the program, as
the non-packet threads were set up the same way as the packet threads.

This patch both no longer sets up the timestamp for non-packet threads
as well as not considering non-packet threads during timestamp
retrieval.

Fixes: 6f560144c1b9 ("time: improve offline time handling")
Bug: #7034.
(cherry picked from commit 54557997952028f4617ca37c583f4a5fd070236c)

src/tm-threads.c

index 1853db6b035ea13b854b9cf6b5e30ec98e0960b0..2e32b6d0bc85ed47e340a16d3028b647bb16d508 100644 (file)
@@ -2213,6 +2213,8 @@ bool TmThreadsTimeSubsysIsReady(void)
         Thread *t = &thread_store.threads[s];
         if (!t->in_use)
             break;
+        if (t->type != TVT_PPT)
+            continue;
         if (t->sys_sec_stamp == 0) {
             ready = false;
             break;
@@ -2231,6 +2233,8 @@ void TmThreadsInitThreadsTimestamp(const SCTime_t ts)
         Thread *t = &thread_store.threads[s];
         if (!t->in_use)
             break;
+        if (t->type != TVT_PPT)
+            continue;
         t->pktts = ts;
         t->sys_sec_stamp = (uint32_t)systs.tv_sec;
     }
@@ -2251,6 +2255,9 @@ void TmThreadsGetMinimalTimestamp(struct timeval *ts)
         Thread *t = &thread_store.threads[s];
         if (t->in_use == 0)
             break;
+        /* only packet threads set timestamps based on packets */
+        if (t->type != TVT_PPT)
+            continue;
         struct timeval pkttv = { .tv_sec = SCTIME_SECS(t->pktts),
             .tv_usec = SCTIME_USECS(t->pktts) };
         if (!(timercmp(&pkttv, &nullts, ==))) {