mirror of
https://github.com/nmap/nmap.git
synced 2026-02-01 19:19:09 +00:00
Avoid retrying iod_read if we already got ENOTSOCK.
This commit is contained in:
@@ -603,6 +603,7 @@ static int do_actual_read(struct npool *ms, struct nevent *nse) {
|
||||
int err = 0;
|
||||
int max_chunk = NSOCK_READ_CHUNK_SIZE;
|
||||
int startlen = fs_length(&nse->iobuf);
|
||||
int enotsock = 0; /* Did we get ENOTSOCK once? */
|
||||
|
||||
if (nse->readinfo.read_type == NSOCK_READBYTES)
|
||||
max_chunk = nse->readinfo.num;
|
||||
@@ -613,16 +614,24 @@ static int do_actual_read(struct npool *ms, struct nevent *nse) {
|
||||
socklen_t peerlen;
|
||||
peerlen = sizeof(peer);
|
||||
|
||||
buflen = ms->engine->io_operations->iod_read(ms, iod->sd, buf, sizeof(buf), 0, (struct sockaddr *)&peer, &peerlen);
|
||||
if (enotsock) {
|
||||
peer.ss_family = AF_UNSPEC;
|
||||
peerlen = 0;
|
||||
buflen = read(iod->sd, buf, sizeof(buf));
|
||||
}
|
||||
else {
|
||||
buflen = ms->engine->io_operations->iod_read(ms, iod->sd, buf, sizeof(buf), 0, (struct sockaddr *)&peer, &peerlen);
|
||||
|
||||
/* Using recv() was failing, at least on UNIX, for non-network sockets
|
||||
* (i.e. stdin) in this case, a read() is done - as on ENOTSOCK we may
|
||||
* have a non-network socket */
|
||||
if (buflen == -1) {
|
||||
if (socket_errno() == ENOTSOCK) {
|
||||
peer.ss_family = AF_UNSPEC;
|
||||
peerlen = 0;
|
||||
buflen = read(iod->sd, buf, sizeof(buf));
|
||||
/* Using recv() was failing, at least on UNIX, for non-network sockets
|
||||
* (i.e. stdin) in this case, a read() is done - as on ENOTSOCK we may
|
||||
* have a non-network socket */
|
||||
if (buflen == -1) {
|
||||
if (socket_errno() == ENOTSOCK) {
|
||||
enotsock = 1;
|
||||
peer.ss_family = AF_UNSPEC;
|
||||
peerlen = 0;
|
||||
buflen = read(iod->sd, buf, sizeof(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buflen == -1) {
|
||||
|
||||
Reference in New Issue
Block a user