From 117b0e2b2b93687ee3a449f1ace296c517da8b2a Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 12 Dec 2022 21:01:36 +0000 Subject: [PATCH] Move a calculation outside the loop --- scan_engine.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scan_engine.cc b/scan_engine.cc index 8d86780fd..b0299e2bc 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -1147,6 +1147,8 @@ int UltraScanInfo::removeCompletedHosts() { /* We don't want to run this all of the time */ TIMEVAL_MSEC_ADD(compare, lastCompletedHostRemoval, completedHostLifetime / 2); if (TIMEVAL_AFTER(now, compare) ) { + /* Remove any that were completed before this time: */ + TIMEVAL_MSEC_ADD(compare, now, -completedHostLifetime); for (hostI = completedHosts.begin(); hostI != completedHosts.end(); hostI = nxt) { nxt = hostI; nxt++; @@ -1156,8 +1158,7 @@ int UltraScanInfo::removeCompletedHosts() { if (hss == gstats->pinghost) continue; - TIMEVAL_MSEC_ADD(compare, hss->completiontime, completedHostLifetime); - if (TIMEVAL_AFTER(now, compare) ) { + if (TIMEVAL_BEFORE(hss->completiontime, compare) ) { /* Any active probes in completed hosts count against our global * cwnd, so be sure to remove them or we can run out of space. */ hss->destroyAllOutstandingProbes();