@@ -2437,14 +2437,18 @@ static void retransmitProbe(UltraScanInfo *USI, HostScanStats *hss,
2437
2437
USI->gstats ->probes_sent ++;
2438
2438
}
2439
2439
2440
+ struct ProbeCacheNode {
2441
+ HostScanStats *hss;
2442
+ std::list<UltraProbe *>::iterator probeI;
2443
+ };
2444
+
2440
2445
/* Go through the ProbeQueue of each host, identify any
2441
2446
timed out probes, then try to retransmit them as appropriate */
2442
2447
static void doAnyOutstandingRetransmits (UltraScanInfo *USI) {
2443
2448
std::multiset<HostScanStats *, HssPredicate>::iterator hostI;
2444
- std::list<UltraProbe *>::iterator probeI;
2445
2449
/* A cache of the last processed probe from each host, to avoid re-examining a
2446
2450
bunch of probes to find the next one that needs to be retransmitted. */
2447
- std::map<HostScanStats *, std::list<UltraProbe *>::iterator > probe_cache;
2451
+ std::vector< struct ProbeCacheNode > probe_cache;
2448
2452
HostScanStats *host = NULL ;
2449
2453
UltraProbe *probe = NULL ;
2450
2454
int retrans = 0 ; /* Number of retransmissions during a loop */
@@ -2457,14 +2461,29 @@ static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
2457
2461
if (o.debugging )
2458
2462
tv_start = USI->now ;
2459
2463
2464
+ probe_cache.reserve (USI->numIncompleteHosts ());
2465
+ for (hostI = USI->incompleteHosts .begin ();
2466
+ hostI != USI->incompleteHosts .end ();
2467
+ hostI++) {
2468
+ struct ProbeCacheNode pcn;
2469
+ pcn.hss = *hostI;
2470
+ /* Skip this host if it has nothing to send. */
2471
+ if (pcn.hss ->num_probes_active == 0
2472
+ && pcn.hss ->num_probes_waiting_retransmit == 0 )
2473
+ continue ;
2474
+ assert (!pcn.hss ->probes_outstanding .empty ());
2475
+ pcn.probeI = pcn.hss ->probes_outstanding .end ();
2476
+ probe_cache.push_back (pcn);
2477
+ }
2460
2478
/* Loop until we get through all the hosts without a retransmit or we're not
2461
2479
OK to send any more. */
2462
2480
do {
2463
2481
retrans = 0 ;
2464
- for (hostI = USI->incompleteHosts .begin ();
2465
- hostI != USI->incompleteHosts .end () && USI->gstats ->sendOK (NULL );
2466
- hostI++) {
2467
- host = *hostI;
2482
+ for (std::vector<struct ProbeCacheNode >::iterator pci = probe_cache.begin ();
2483
+ pci != probe_cache.end () && USI->gstats ->sendOK (NULL );
2484
+ pci++) {
2485
+ host = pci->hss ;
2486
+ std::list<UltraProbe *>::iterator &probeI = pci->probeI ;
2468
2487
/* Skip this host if it has nothing to send. */
2469
2488
if ((host->num_probes_active == 0
2470
2489
&& host->num_probes_waiting_retransmit == 0 ))
@@ -2473,12 +2492,6 @@ static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
2473
2492
continue ;
2474
2493
assert (!host->probes_outstanding .empty ());
2475
2494
2476
- /* Initialize the probe cache if necessary. */
2477
- if (probe_cache.find (host) == probe_cache.end ())
2478
- probe_cache[host] = host->probes_outstanding .end ();
2479
- /* Restore the probe iterator from the cache. */
2480
- probeI = probe_cache[host];
2481
-
2482
2495
maxtries = host->allowedTryno (NULL , NULL );
2483
2496
do {
2484
2497
probeI--;
@@ -2508,8 +2521,6 @@ static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
2508
2521
/* Wrap the probe iterator around. */
2509
2522
if (probeI == host->probes_outstanding .begin ())
2510
2523
probeI = host->probes_outstanding .end ();
2511
- /* Cache the probe iterator. */
2512
- probe_cache[host] = probeI;
2513
2524
}
2514
2525
} while (USI->gstats ->sendOK (NULL ) && retrans != 0 );
2515
2526
0 commit comments