]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow-bypass: fix sleep strategy
authorEric Leblond <eric@regit.org>
Thu, 28 Dec 2017 18:17:56 +0000 (19:17 +0100)
committerEric Leblond <eric@regit.org>
Tue, 6 Feb 2018 15:58:19 +0000 (16:58 +0100)
src/flow-bypass.c

index 790e00408ac7e5e146908c09f8c26d37c08a942a..b3a7b63fd03a2bbac28681adadbf6b92ea42f634 100644 (file)
@@ -45,7 +45,6 @@ static TmEcode BypassedFlowManager(ThreadVars *th_v, void *thread_data)
 #ifdef HAVE_PACKET_EBPF
     int tcount = 0;
     BypassedFlowManagerThreadData *ftd = thread_data;
-
     while (1) {
         int i;
         SCLogDebug("Dumping the table");
@@ -53,7 +52,7 @@ static TmEcode BypassedFlowManager(ThreadVars *th_v, void *thread_data)
         if (clock_gettime(CLOCK_MONOTONIC, &curtime) != 0) {
             SCLogWarning(SC_ERR_INVALID_VALUE, "Can't get time: %s (%d)",
                          strerror(errno), errno);
-            sleep(1);
+            usleep(10000);
             continue;
         }
         for (i = 0; i < g_bypassed_func_max_index; i++) {
@@ -70,8 +69,14 @@ static TmEcode BypassedFlowManager(ThreadVars *th_v, void *thread_data)
             StatsSyncCounters(th_v);
             return TM_ECODE_OK;
         }
-        sleep(FLOW_BYPASS_DELAY);
-        StatsSyncCountersIfSignalled(th_v);
+        for (i = 0; i < FLOW_BYPASS_DELAY * 100; i++) {
+            if (TmThreadsCheckFlag(th_v, THV_KILL)) {
+                StatsSyncCounters(th_v);
+                return TM_ECODE_OK;
+            }
+            StatsSyncCountersIfSignalled(th_v);
+            usleep(10000);
+        }
     }
 #endif
     return TM_ECODE_OK;