]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
time: replace usleep by SleepUsec/SleepMsec
authorVictor Julien <vjulien@oisf.net>
Tue, 10 Jun 2025 10:47:25 +0000 (12:47 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 10 Jun 2025 20:13:54 +0000 (22:13 +0200)
Helps cross platform support, esp Windows

src/detect-engine.c
src/flow-bypass.c
src/flow-manager.c
src/log-flush.c
src/source-pcap.c

index 7c6e9c13630fcfddb37e0c3024bbafc164c255c0..bb9b41572df9e42c97db58feb99cd22ff47cadd1 100644 (file)
@@ -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);
             }
         }
     }
index a57909c6ff295c8b55177650faff7d50c2998125..94e8afeba8d196842c40c60c3d00361e06346930 100644 (file)
@@ -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;
index 26b9485652f9bb3540248803c37bc18775c5218e..0b074acb253ea07ea0ad27e0befb6376125033cd 100644 (file)
@@ -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);
index f9ab98b0688fd9458eb1ba60cf0fa628e339e6c4..8da1157df7d5d23c6ad57b8974360386ce4116e3 100644 (file)
@@ -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++;
index cb520a2b490936759b60c3e960e5f5247edae4df..b278aecb45a25aa3794c8bfbe4c494255dfc1d14 100644 (file)
@@ -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;