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:
@@ -62,8 +62,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern struct timeval nsock_tod;
|
|
||||||
|
|
||||||
/* Create the actual socket (nse->iod->sd) underlying the iod. This unblocks the
|
/* 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
|
* socket, binds to the localaddr address, sets IP options, and sets the
|
||||||
* broadcast flag. Trying to change these functions after making this call will
|
* 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);
|
assert(nsi->state == NSIOD_STATE_INITIAL || nsi->state == NSIOD_STATE_UNKNOWN);
|
||||||
|
|
||||||
gettimeofday(&nsock_tod, NULL);
|
|
||||||
|
|
||||||
if (ms->tracelevel > 0)
|
if (ms->tracelevel > 0)
|
||||||
nsock_trace(ms, "UDP unconnected socket (IOD #%li)", nsi->id);
|
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);
|
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);
|
nse = msevent_new(ms, NSE_TYPE_CONNECT, nsi, timeout_msecs, handler, userdata);
|
||||||
assert(nse);
|
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);
|
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);
|
nse = msevent_new(ms, NSE_TYPE_CONNECT, nsi, timeout_msecs, handler, userdata);
|
||||||
assert(nse);
|
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;
|
mspool *ms = (mspool *)nsp;
|
||||||
msevent *nse;
|
msevent *nse;
|
||||||
|
|
||||||
/* Just in case someone waits a long time and then does a new connect */
|
|
||||||
gettimeofday(&nsock_tod, NULL);
|
|
||||||
|
|
||||||
if (!ms->sslctx)
|
if (!ms->sslctx)
|
||||||
nsp_ssl_init(ms);
|
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);
|
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);
|
nse = msevent_new(ms, NSE_TYPE_CONNECT, nsi, -1, handler, userdata);
|
||||||
assert(nse);
|
assert(nse);
|
||||||
|
|
||||||
|
|||||||
@@ -398,6 +398,9 @@ msevent *msevent_new(mspool *nsp, enum nse_type type, msiod *msiod, int timeout_
|
|||||||
nsock_ev_handler handler, void *userdata) {
|
nsock_ev_handler handler, void *userdata) {
|
||||||
msevent *nse;
|
msevent *nse;
|
||||||
|
|
||||||
|
/* Bring us up to date for the timeout calculation. */
|
||||||
|
gettimeofday(&nsock_tod, NULL);
|
||||||
|
|
||||||
if (msiod) {
|
if (msiod) {
|
||||||
msiod->events_pending++;
|
msiod->events_pending++;
|
||||||
assert(msiod->state != NSIOD_STATE_DELETED);
|
assert(msiod->state != NSIOD_STATE_DELETED);
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ nsock_event_id nsock_timer_create(nsock_pool ms_pool, nsock_ev_handler handler,
|
|||||||
mspool *nsp = (mspool *)ms_pool;
|
mspool *nsp = (mspool *)ms_pool;
|
||||||
msevent *nse;
|
msevent *nse;
|
||||||
|
|
||||||
gettimeofday(&nsock_tod, NULL);
|
|
||||||
|
|
||||||
nse = msevent_new(nsp, NSE_TYPE_TIMER, NULL, timeout_msecs, handler, userdata);
|
nse = msevent_new(nsp, NSE_TYPE_TIMER, NULL, timeout_msecs, handler, userdata);
|
||||||
assert(nse);
|
assert(nse);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user