1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-08 23:49:03 +00:00

[NSOCK] Fixed an epoll-engine-specific bug. The engine didn't recognized FDs

that were internally closed and replaced by other ones. This happened during
reconnect attempts.

--

When reconnecting with SSL_OP_NO_SSLv2 (nsock_core.c:472), the libary closes the
fd of the current IOD, and replaces it by a new one.

The man page for epoll_ctl states that a close() on a fd makes it removed from
any epoll set it was in. Therefore, if epoll_ctl(EPOLL_CTL_MOD, ...) returns
ENOENT, we retry with EPOLL_CTL_ADD.
This commit is contained in:
henri
2012-07-05 14:35:51 +00:00
parent d86d3f68c2
commit 9baacdf9e3
2 changed files with 14 additions and 1 deletions

View File

@@ -1,4 +1,8 @@
# Nmap Changelog ($Id$); -*-text-*-
o [NSOCK] Fixed an epoll-engine-specific bug. The engine didn't recognized FDs
that were internally closed and replaced by other ones. This happened during
reconnect attempts. [Henri Doreau]
o Added support for log type bitmasks in log_vwrite(). Also replaced a fatal()
statement by an assert(0) to get rid of a possible infinite call loop when
passed an invalid log type. [Henri Doreau]

View File

@@ -230,7 +230,16 @@ int epoll_iod_modify(mspool *nsp, msiod *iod, int ev_set, int ev_clr) {
epev.events |= EPOLL_X_FLAGS;
sd = nsi_getsd(iod);
epoll_ctl(einfo->epfd, EPOLL_CTL_MOD, sd, &epev);
if (epoll_ctl(einfo->epfd, EPOLL_CTL_MOD, sd, &epev) < 0) {
if (errno == ENOENT) {
/* This IOD is registered but its associated fd is not in the epoll set.
* It was probably closed and another one was open (e.g.: reconnect operation).
* We therefore want to add the new one. */
epoll_ctl(einfo->epfd, EPOLL_CTL_ADD, sd, &epev);
} else {
fatal("Unable to update events for IOD #%lu: %s", iod->id, strerror(errno));
}
}
return 1;
}