]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stats: more accurate time handling for wakeup thread
authorVictor Julien <victor@inliniac.net>
Wed, 12 Jun 2019 05:34:21 +0000 (07:34 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 17 Jun 2019 18:06:50 +0000 (20:06 +0200)
src/counters.c

index 5185e2c9707b42d0b49bbf2c53055c5bf008bec1..3880043c76e6b525fd0f9f6184a6f26d655c10b9 100644 (file)
@@ -439,7 +439,6 @@ static void *StatsMgmtThread(void *arg)
 static void *StatsWakeupThread(void *arg)
 {
     ThreadVars *tv_local = (ThreadVars *)arg;
-    struct timespec cond_time;
 
     /* Set the thread name */
     if (SCSetThreadName(tv_local->name) < 0) {
@@ -468,8 +467,10 @@ static void *StatsWakeupThread(void *arg)
             TmThreadsUnsetFlag(tv_local, THV_PAUSED);
         }
 
-        cond_time.tv_sec = time(NULL) + STATS_WUT_TTS;
-        cond_time.tv_nsec = 0;
+        struct timeval cur_timev;
+        gettimeofday(&cur_timev, NULL);
+        struct timespec cond_time = FROM_TIMEVAL(cur_timev);
+        cond_time.tv_sec += STATS_WUT_TTS;
 
         /* wait for the set time, or until we are woken up by
          * the shutdown procedure */