From 37d623d070f4ea526191a9fb9d460a5ab5115986 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 17 May 2012 22:04:13 +0000 Subject: [PATCH] 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 --- libnetutil/netutil.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index 1d5b4966e..5d0bf90fa 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -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);