time: replace usleep by SleepUsec/SleepMsec

Helps cross platform support, esp Windows
pull/13419/head
Victor Julien 1 year ago committed by Victor Julien
parent 35e711d00a
commit c3f054b625

@ -2411,7 +2411,7 @@ retry:
threads_done = no_of_detect_tvs;
break;
}
usleep(1000);
SleepMsec(1);
if (SC_ATOMIC_GET(new_det_ctx[i]->so_far_used_by_detect) == 1) {
SCLogDebug("new_det_ctx - %p used by detect engine", new_det_ctx[i]);
threads_done++;
@ -2437,7 +2437,7 @@ retry:
}
while (!TmThreadsCheckFlag(tv, THV_RUNNING_DONE)) {
usleep(100);
SleepUsec(100);
}
}
}

@ -123,7 +123,7 @@ static TmEcode BypassedFlowManager(ThreadVars *th_v, void *thread_data)
return TM_ECODE_OK;
}
StatsSyncCountersIfSignalled(th_v);
usleep(10000);
SleepMsec(10);
}
}
return TM_ECODE_OK;

@ -841,7 +841,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
while (!TimeModeIsReady()) {
if (suricata_ctl_flags != 0)
return TM_ECODE_OK;
usleep(10);
SleepUsec(10);
}
bool run = TmThreadsWaitForUnpause(th_v);
@ -965,7 +965,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
}
if (emerg || !time_is_live) {
usleep(250);
SleepUsec(250);
} else {
struct timeval cond_tv;
gettimeofday(&cond_tv, NULL);
@ -1145,7 +1145,7 @@ static TmEcode FlowRecycler(ThreadVars *th_v, void *thread_data)
const bool emerg = (SC_ATOMIC_GET(flow_flags) & FLOW_EMERGENCY);
if (emerg || !time_is_live) {
usleep(250);
SleepUsec(250);
} else {
struct timeval cond_tv;
gettimeofday(&cond_tv, NULL);
@ -1240,7 +1240,7 @@ void FlowDisableFlowRecyclerThread(void)
/* make sure all flows are processed */
do {
FlowWakeupFlowRecyclerThread();
usleep(10);
SleepUsec(10);
} while (!FlowRecyclerReadyToShutdown());
SCMutexLock(&tv_root_lock);

@ -100,7 +100,7 @@ retry:
threads_done = no_of_detect_tvs;
break;
}
usleep(1000);
SleepMsec(1);
if (fw_threads[i] && FlowWorkerGetFlushAck(fw_threads[i])) {
SCLogDebug("thread slot %d has ack'd flush request", i);
threads_done++;
@ -164,7 +164,7 @@ static void *LogFlusherWakeupThread(void *arg)
uint64_t worker_flush_count = 0;
bool run = TmThreadsWaitForUnpause(tv_local);
while (run) {
usleep(log_flush_sleep_time * 1000);
SleepMsec(log_flush_sleep_time);
if (++wait_count == flush_wait_count) {
worker_flush_count++;

@ -422,7 +422,7 @@ static TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot)
int dbreak = 0;
SCLogError("error code %" PRId32 " %s", r, pcap_geterr(ptv->pcap_handle));
do {
usleep(PCAP_RECONNECT_TIMEOUT);
SleepUsec(PCAP_RECONNECT_TIMEOUT);
if (suricata_ctl_flags != 0) {
dbreak = 1;
break;

Loading…
Cancel
Save