ThreadVars *tv_local = (ThreadVars *)arg;
uint8_t run = 1;
- struct timespec cond_time;
/* Set the thread name */
if (SCSetThreadName(tv_local->name) < 0) {
TmThreadsUnsetFlag(tv_local, THV_PAUSED);
}
- cond_time.tv_sec = time(NULL) + stats_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_tts);
/* wait for the set time, or until we are woken up by
* the shutdown procedure */
void TimeSetByThread(const int thread_id, const struct timeval *tv);
void TimeGet(struct timeval *);
+/** \brief intialize a 'struct timespec' from a 'struct timeval'. */
+#define FROM_TIMEVAL(timev) { .tv_sec = (timev).tv_sec, .tv_nsec = (timev).tv_usec * 1000 }
+
#ifdef UNITTESTS
void TimeSet(struct timeval *);
void TimeSetToCurrentTime(void);