From e2d31e1c571bc63da76ebf37d4aeb86e4269c965 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Thu, 28 Dec 2017 19:17:56 +0100 Subject: [PATCH] flow-bypass: fix sleep strategy --- src/flow-bypass.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/flow-bypass.c b/src/flow-bypass.c index 790e00408a..b3a7b63fd0 100644 --- a/src/flow-bypass.c +++ b/src/flow-bypass.c @@ -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;