mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 06:40:48 +00:00
Change the conditions for printing a timing status update to what I think they
were intended to be. We are okay to print if
1. We don't have a completion time estimate yet; or
2. We have passed the last completion time estimate; or
3. The estimated time remaining differs from the last one printed by more
than 3 minutes, and the difference accounts for more than 5% of the
estimated total time.
The problem was that the last printed time remaining was calculated not as
difftime(last_est.tv_sec, last_print.tv_sec), but as
difftime(last_est.tv_sec, now->tv_sec). In other words it was constantly
changing, and at the same rate as the estimated time left (if the scan was
progressing at a constant rate). That means that as soon as a completion time
estimate was fairly accurate, you would not get any more estimates because the
difference in the two times would always be small.
This commit is contained in:
parent
898c2a41a0
commit
e0250c1b66
1 changed files with 12 additions and 14 deletions
26
timing.cc
26
timing.cc
|
|
@ -513,8 +513,6 @@ bool ScanProgressMeter::printStatsIfNecessary(double perc_done,
|
|||
const struct timeval *now) {
|
||||
struct timeval tvtmp;
|
||||
double time_left_s;
|
||||
double prev_est_time_left_s; /* Time left as per prev. estimate */
|
||||
double change_abs_s; /* absolute value of change */
|
||||
bool printit = false;
|
||||
|
||||
if (!now) {
|
||||
|
|
@ -537,19 +535,19 @@ bool ScanProgressMeter::printStatsIfNecessary(double perc_done,
|
|||
if (time_left_s < 30)
|
||||
return false; /* No point in updating when it is virtually finished. */
|
||||
|
||||
/* If we have not printed before, or if our previous ETC has elapsed, print
|
||||
a new one */
|
||||
if (last_print.tv_sec == 0)
|
||||
if (last_est.tv_sec == 0) {
|
||||
/* We don't have an estimate yet (probably means a low completion). */
|
||||
printit = true;
|
||||
else {
|
||||
/* If the estimate changed by more than X minutes, and if that
|
||||
change represents at least X% of the time remaining, print
|
||||
it. */
|
||||
prev_est_time_left_s = difftime(last_est.tv_sec, now->tv_sec);
|
||||
change_abs_s = ABS(prev_est_time_left_s - time_left_s);
|
||||
if (prev_est_time_left_s <= 0)
|
||||
printit = true;
|
||||
else if (o.debugging || (change_abs_s > 180 && change_abs_s > .05 * MAX(time_left_s, prev_est_time_left_s)))
|
||||
} else if (TIMEVAL_AFTER(*now, last_est)) {
|
||||
/* The last estimate we printed has passed. Print a new one. */
|
||||
printit = true;
|
||||
} else {
|
||||
/* If the estimate changed by more than 3 minutes, and if that change
|
||||
represents at least 5% of the total time, print it. */
|
||||
double prev_est_total_time_s = difftime(last_est.tv_sec, begin.tv_sec);
|
||||
double prev_est_time_left_s = difftime(last_est.tv_sec, last_print.tv_sec);
|
||||
double change_abs_s = ABS(prev_est_time_left_s - time_left_s);
|
||||
if (o.debugging || (change_abs_s > 15 && change_abs_s > .05 * prev_est_total_time_s))
|
||||
printit = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue