From e0435b8b986f2cef6919f430a542a5c2d25bae06 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 19 Aug 2008 17:01:44 +0000 Subject: [PATCH] Go back to the old method of calculating the completion percentage. My clever formula algebraically reduced to 1.0 - gstats->numprobes / host->freshPortsLeft(), which doesn't regard the number of sent probes, leading to long stalls in the completion when, for example, maxtries is increased. --- scan_engine.cc | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/scan_engine.cc b/scan_engine.cc index f7fdfe873..7c6440eb5 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -1366,21 +1366,16 @@ double UltraScanInfo::getCompletionFraction() { /* Get the completion fraction for each incomplete host. */ for(hostI = incompleteHosts.begin(); hostI != incompleteHosts.end(); hostI++) { HostScanStats *host = *hostI; - int ports_left; - double rate; - double probes_left; + int maxtries = host->allowedTryno(NULL, NULL) + 1; + double thishostpercdone; - ports_left = host->freshPortsLeft(); - if (ports_left == gstats->numprobes) - continue; - /* Get the overall rate of probes sent to ports completed. */ - rate = (double) host->numprobes_sent / (gstats->numprobes - ports_left); - /* Find out how many probes it will take to scan the remainder of the ports - at that rate. */ - probes_left = rate * ports_left; - /* Get the completion fraction: number of probes sent divided by estimated - total number of probes. */ - total += (double) host->numprobes_sent / (host->numprobes_sent + probes_left); + // This is inexact (maxtries - 1) because numprobes_sent includes + // at least one try of ports_finished. + thishostpercdone = host->ports_finished * (maxtries - 1) + host->numprobes_sent; + thishostpercdone /= maxtries * gstats->numprobes; + if (thishostpercdone >= 0.9999) + thishostpercdone = 0.9999; + total += thishostpercdone; } return total / gstats->numtargets;