From 0cfe81cc2b1b248de7466e29df4d327dc9345888 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 11 Sep 2023 07:05:48 +0200 Subject: [PATCH] host/iprep: run all timeout logic Run all timeout logic if iprep is in use as well. Minor code cleanups. Bug: #6436. (cherry picked from commit 6307a4d4b93d000d4c5e19434a6dd3958946dcd8) --- src/host-timeout.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/host-timeout.c b/src/host-timeout.c index ccb9214983..7d7d284a18 100644 --- a/src/host-timeout.c +++ b/src/host-timeout.c @@ -53,9 +53,7 @@ uint32_t HostGetActiveCount(void) */ static int HostHostTimedOut(Host *h, struct timeval *ts) { - int tags = 0; - int thresholds = 0; - int vars = 0; + int busy = 0; /** never prune a host that is used by a packet * we are currently processing in one of the threads */ @@ -63,28 +61,12 @@ static int HostHostTimedOut(Host *h, struct timeval *ts) return 0; } - if (h->iprep) { - if (SRepHostTimedOut(h) == 0) - return 0; - - SCLogDebug("host %p reputation timed out", h); - } - - if (TagHostHasTag(h) && TagTimeoutCheck(h, ts) == 0) { - tags = 1; - } - if (ThresholdHostHasThreshold(h) && ThresholdHostTimeoutCheck(h, ts) == 0) { - thresholds = 1; - } - if (HostHasHostBits(h) && HostBitsTimedoutCheck(h, ts) == 0) { - vars = 1; - } - - if (tags || thresholds || vars) - return 0; - - SCLogDebug("host %p timed out", h); - return 1; + busy |= (h->iprep && SRepHostTimedOut(h) == 0); + busy |= (TagHostHasTag(h) && TagTimeoutCheck(h, ts) == 0); + busy |= (ThresholdHostHasThreshold(h) && ThresholdHostTimeoutCheck(h, ts) == 0); + busy |= (HostHasHostBits(h) && HostBitsTimedoutCheck(h, ts) == 0); + SCLogDebug("host %p %s", h, busy ? "still active" : "timed out"); + return !busy; } /** -- 2.47.2