]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow-manager: call other timeouts max once a second
authorVictor Julien <victor@inliniac.net>
Tue, 24 Dec 2019 15:12:51 +0000 (16:12 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 6 Aug 2020 09:43:46 +0000 (11:43 +0200)
Call Defrag and others only once per second. Flow Manager may wake
up (much) more often when flow engine is under resource pressure.
As this does not affect Defrag and others, it only unnecessarily
adds load.

src/flow-manager.c

index b8bb87acef7ee5e4c6d06dacf9b09e3f348dda05..21f3dcf9ca912d0fcbab316145ff5e9abd400397 100644 (file)
@@ -693,6 +693,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
     struct timespec cond_time;
     int flow_update_delay_sec = FLOW_NORMAL_MODE_UPDATE_DELAY_SEC;
     int flow_update_delay_nsec = FLOW_NORMAL_MODE_UPDATE_DELAY_NSEC;
+    uint32_t other_last_sec = 0; /**< last sec stamp when defrag etc ran */
 /* VJ leaving disabled for now, as hosts are only used by tags and the numbers
  * are really low. Might confuse ppl
     uint16_t flow_mgr_host_prune = StatsRegisterCounter("hosts.pruned", th_v);
@@ -741,11 +742,13 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
         FlowTimeoutHash(&ts, 0 /* check all */, ftd->min, ftd->max, &counters);
 
 
-        if (ftd->instance == 0) {
+        if (ftd->instance == 0 &&
+                (other_last_sec == 0 || other_last_sec < (uint32_t)ts.tv_sec)) {
             DefragTimeoutHash(&ts);
             //uint32_t hosts_pruned =
             HostTimeoutHash(&ts);
             IPPairTimeoutHash(&ts);
+            other_last_sec = (uint32_t)ts.tv_sec;
         }
 /*
         StatsAddUI64(th_v, flow_mgr_host_prune, (uint64_t)hosts_pruned);