From 8c231702d9885b4821e9e1eb2c0cc7567ca7d4fb Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 22 May 2014 12:53:51 +0200 Subject: [PATCH] flow-recycler: speed up flow-recycler shutdown Thread was killed by the generic TmThreadKillThreads instead of the FlowKillFlowRecyclerThread. The latter wakes the thread up, so that shutdown is quite a bit faster. --- src/flow-manager.c | 2 ++ src/suricata.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/flow-manager.c b/src/flow-manager.c index d175f02bb4..bea4b6b351 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -769,6 +769,8 @@ void FlowKillFlowRecyclerThread(void) TmThreadsSetFlag(tv, THV_KILL); TmThreadsSetFlag(tv, THV_DEINIT); + SCCtrlCondSignal(&flow_recycler_ctrl_cond); + /* be sure it has shut down */ while (!TmThreadsCheckFlag(tv, THV_CLOSED)) { usleep(100); diff --git a/src/suricata.c b/src/suricata.c index ebbea361f2..9be6671abd 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -2402,11 +2402,16 @@ int main(int argc, char **argv) BUG_ON(global_de_ctx == NULL); } + /* before TmThreadKillThreads, as otherwise that kills it + * but more slowly */ + if (suri.run_mode != RUNMODE_UNIX_SOCKET) { + FlowKillFlowRecyclerThread(); + } + TmThreadKillThreads(); if (suri.run_mode != RUNMODE_UNIX_SOCKET) { SCPerfReleaseResources(); - FlowKillFlowRecyclerThread(); FlowShutdown(); StreamTcpFreeConfig(STREAM_VERBOSE); }