1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-30 11:29:01 +00:00

Limit the errors that cause Sendto to sleep and retry.

Sendto has logic to automatically sleep and retry a send if it fails.
Fyodor tells me that it was once necessary because of some transient
buffer shortage, though we can't remember the exact error it was in
response to.

The retry looks as though it has been slowly growing a list of
exceptional error codes for which sleeping is not done:
	EPERM EACCES EMSGSIZE EADDRNOTAVAIL EINVAL
The latest was EMSGSIZE in r19378.

I changed this to only sleep on specific errors. Not knowing what the
original error was, I have guessed
	ENOBUFS ENOMEM
This commit is contained in:
david
2012-05-17 22:04:13 +00:00
parent 9d37d8bdca
commit 37d623d070

View File

@@ -3395,8 +3395,10 @@ int Sendto(const char *functionname, int sd,
#if WIN32
return -1;
#else
if (retries > 2 || err == EPERM || err == EACCES || err == EMSGSIZE
|| err == EADDRNOTAVAIL || err == EINVAL)
if (retries > 2)
return -1;
/* For these enumerated errors, we sleep and try again. */
if (!(err == ENOBUFS || err == ENOMEM))
return -1;
sleeptime = 15 * (1 << (2 * retries));
netutil_error("Sleeping %d seconds then retrying", sleeptime);