1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-31 02:29:02 +00:00

Update nsock_tod before creating a timer.

nsock_tod is Nsock's idea of the current time. It is updated when an
nsock_pool is initialized, on each iteration of nsock_loop, and in a few
other places. What could go wrong, with respect to timers, is a sequence
like this:
	nsp_new
	[... some long delay ...]
	nsock_create_timer(timeout)
	nsock_loop
The time elapsed after the creatino of the timer until it fires would
not be timeout, but rather timeout - delay. If the delay was long
enough, the timer would fire as loop as nsock_loop was entered.

This showed itself in IPv6 OS detection. We schedule 6 timers
immediately, 100 ms apart. If the pcap_open or anything else took too
long, then the timers would fire all at once. This messed up the
calculation of the TCP_ISR feature.

Perhaps we should do this when any new event is created? It is already
done manually at the beginning of each of the connect functions.
This commit is contained in:
david
2012-03-16 20:02:57 +00:00
parent 95d0ced45a
commit 9cd1ef697b
2 changed files with 8 additions and 0 deletions

View File

@@ -57,6 +57,8 @@
#include "nsock_internal.h"
extern struct timeval nsock_tod;
/* Send back an NSE_TYPE_TIMER after the number of milliseconds specified. Of
* course it can also return due to error, cancellation, etc. */
nsock_event_id nsock_timer_create(nsock_pool ms_pool, nsock_ev_handler handler,
@@ -64,6 +66,8 @@ nsock_event_id nsock_timer_create(nsock_pool ms_pool, nsock_ev_handler handler,
mspool *nsp = (mspool *)ms_pool;
msevent *nse;
gettimeofday(&nsock_tod, NULL);
nse = msevent_new(nsp, NSE_TYPE_TIMER, NULL, timeout_msecs, handler, userdata);
assert(nse);