From: Victor Julien Date: Wed, 12 Jun 2019 05:34:21 +0000 (+0200) Subject: stats: more accurate time handling for wakeup thread X-Git-Tag: suricata-5.0.0-rc1~405 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9474b846834bf3ab6929030023691262cbf4ba32;p=thirdparty%2Fsuricata.git stats: more accurate time handling for wakeup thread --- diff --git a/src/counters.c b/src/counters.c index 5185e2c970..3880043c76 100644 --- a/src/counters.c +++ b/src/counters.c @@ -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 */