From 44c3b5abc861d9cbcbf091fdda65d817a2561e62 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 1 Mar 2024 19:29:54 +0000 Subject: [PATCH] Optimize loop check in doAnyOutstandingRetransmits: head of list does not change --- scan_engine.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scan_engine.cc b/scan_engine.cc index 0f89afa62..4ab7f5235 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -2462,6 +2462,8 @@ static void doAnyOutstandingRetransmits(UltraScanInfo *USI) { pci++) { host = pci->hss; std::list::iterator &probeI = pci->probeI; + // Nothing drops off list during this function + const std::list::const_iterator &beginI = host->probes_outstanding.begin(); /* Skip this host if it has nothing to send. */ if ((host->num_probes_active == 0 && host->num_probes_waiting_retransmit == 0)) @@ -2494,10 +2496,10 @@ static void doAnyOutstandingRetransmits(UltraScanInfo *USI) { } break; /* I only do one probe per host for now to spread load */ } - } while (probeI != host->probes_outstanding.begin()); + } while (probeI != beginI); /* Wrap the probe iterator around. */ - if (probeI == host->probes_outstanding.begin()) + if (probeI == beginI) probeI = host->probes_outstanding.end(); } } while (USI->gstats->sendOK(NULL) && retrans != 0);