From ccf6e15b90de3cf72f0bfe2c7cf081fa92715ecf Mon Sep 17 00:00:00 2001 From: henri Date: Wed, 11 Jun 2014 20:14:16 +0000 Subject: [PATCH] Nsock early error reporting. Report finished (likely failed) events as early as possible. Because the corresponding IODs can have no I/O activity, they wouldn't be flagged as active by the I/O engines and the events could end up being delivered at shutdown only (or never). Reported by d33tah on http://seclists.org/nmap-dev/2014/q2/409 --- nsock/src/nsock_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nsock/src/nsock_core.c b/nsock/src/nsock_core.c index 26f5a282b..bfaf23ba9 100644 --- a/nsock/src/nsock_core.c +++ b/nsock/src/nsock_core.c @@ -1323,6 +1323,14 @@ void nsp_add_event(struct npool *nsp, struct nevent *nse) { default: fatal("Unknown nsock event type (%d)", nse->type); } + + /* It can happen that the event already completed. In which case we can + * already deliver it, even though we're probably not inside nsock_loop(). */ + if (nse->event_done) { + event_dispatch_and_delete(nsp, nse, 1); + update_first_events(nse); + nevent_unref(nsp, nse); + } } /* An event has been completed and the handler is about to be called. This