1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-20 14:39:02 +00:00

Centralize nsock_tod updates in msevent_new.

This was being done manually for various types of events, and not doing
it in every case was causing hard-to-find bugs. See the log messages for
r19970 in /nsock and r28292 in /nmap.
This commit is contained in:
david
2012-03-29 17:43:35 +00:00
parent c6e7647f57
commit b1583a66e6
3 changed files with 3 additions and 18 deletions

View File

@@ -62,8 +62,6 @@
#include <errno.h>
#include <string.h>
extern struct timeval nsock_tod;
/* Create the actual socket (nse->iod->sd) underlying the iod. This unblocks the
* socket, binds to the localaddr address, sets IP options, and sets the
* broadcast flag. Trying to change these functions after making this call will
@@ -112,8 +110,6 @@ int nsock_setup_udp(nsock_pool nsp, nsock_iod ms_iod, int af) {
assert(nsi->state == NSIOD_STATE_INITIAL || nsi->state == NSIOD_STATE_UNKNOWN);
gettimeofday(&nsock_tod, NULL);
if (ms->tracelevel > 0)
nsock_trace(ms, "UDP unconnected socket (IOD #%li)", nsi->id);
@@ -185,9 +181,6 @@ nsock_event_id nsock_connect_tcp(nsock_pool nsp, nsock_iod ms_iod, nsock_ev_hand
assert(nsi->state == NSIOD_STATE_INITIAL || nsi->state == NSIOD_STATE_UNKNOWN);
/* Just in case someone waits a long time and then does a new connect */
gettimeofday(&nsock_tod, NULL);
nse = msevent_new(ms, NSE_TYPE_CONNECT, nsi, timeout_msecs, handler, userdata);
assert(nse);
@@ -217,9 +210,6 @@ nsock_event_id nsock_connect_sctp(nsock_pool nsp, nsock_iod ms_iod, nsock_ev_han
assert(nsi->state == NSIOD_STATE_INITIAL || nsi->state == NSIOD_STATE_UNKNOWN);
/* Just in case someone waits a long time and then does a new connect */
gettimeofday(&nsock_tod, NULL);
nse = msevent_new(ms, NSE_TYPE_CONNECT, nsi, timeout_msecs, handler, userdata);
assert(nse);
@@ -254,9 +244,6 @@ nsock_event_id nsock_connect_ssl(nsock_pool nsp, nsock_iod nsiod, nsock_ev_handl
mspool *ms = (mspool *)nsp;
msevent *nse;
/* Just in case someone waits a long time and then does a new connect */
gettimeofday(&nsock_tod, NULL);
if (!ms->sslctx)
nsp_ssl_init(ms);
@@ -340,9 +327,6 @@ nsock_event_id nsock_connect_udp(nsock_pool nsp, nsock_iod nsiod, nsock_ev_handl
assert(nsi->state == NSIOD_STATE_INITIAL || nsi->state == NSIOD_STATE_UNKNOWN);
/* Just in case someone waits a long time and then does a new connect */
gettimeofday(&nsock_tod, NULL);
nse = msevent_new(ms, NSE_TYPE_CONNECT, nsi, -1, handler, userdata);
assert(nse);

View File

@@ -398,6 +398,9 @@ msevent *msevent_new(mspool *nsp, enum nse_type type, msiod *msiod, int timeout_
nsock_ev_handler handler, void *userdata) {
msevent *nse;
/* Bring us up to date for the timeout calculation. */
gettimeofday(&nsock_tod, NULL);
if (msiod) {
msiod->events_pending++;
assert(msiod->state != NSIOD_STATE_DELETED);

View File

@@ -66,8 +66,6 @@ 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);