diff --git a/src/flow-hash.c b/src/flow-hash.c index 26aa7efd74..e418a9d9e3 100644 --- a/src/flow-hash.c +++ b/src/flow-hash.c @@ -880,11 +880,18 @@ static Flow *FlowGetUsedFlow(ThreadVars *tv, DecodeThreadVars *dtv) { uint32_t idx = SC_ATOMIC_GET(flow_prune_idx) % flow_config.hash_size; uint32_t cnt = flow_config.hash_size; + uint32_t tried = 0; while (cnt--) { + tried++; if (++idx >= flow_config.hash_size) idx = 0; + if (tried >= 25) { + (void) SC_ATOMIC_ADD(flow_prune_idx, (flow_config.hash_size - cnt)); + break; + } + FlowBucket *fb = &flow_hash[idx]; if (FBLOCK_TRYLOCK(fb) != 0)