diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-03-31 20:36:01 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-03-31 20:36:01 -0700 |
commit | e750801220bf0e56852b319b2d5a4b2d342604d5 (patch) | |
tree | f3f90334eb1d4c9fec79ddda2b4afa9e579c118b /sockutils.c | |
parent | af6aaa6a4fc7a6beb3b8ae5447eb6d30b1cd25cd (diff) |
Don't log errors due to the peer dropping the connection.
They may happen because somebody ^C's a tcpdump; that's not worth
logging.
On UN*X, that might show up as ECONNRESET or EPIPE; on Windows, that
might show up as WSAECONNRESET or WSAECONNABORTED.
Diffstat (limited to 'sockutils.c')
-rw-r--r-- | sockutils.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sockutils.c b/sockutils.c index e7912fbe..2dfa9f90 100644 --- a/sockutils.c +++ b/sockutils.c @@ -640,7 +640,8 @@ int sock_initaddress(const char *host, const char *port, * larger than 'errbuflen - 1' because the last char is reserved for the string terminator. * * \return '0' if everything is fine, '-1' if an error other than - * "connection reset" occurred, '-2' if "connection reset" occurred. + * "connection reset" or "peer has closed the receive side" occurred, + * '-2' if we got one of those errors. * For errors, an error message is returned in the 'errbuf' variable. */ int sock_send(SOCKET sock, const char *buffer, size_t size, @@ -686,15 +687,30 @@ int sock_send(SOCKET sock, const char *buffer, size_t size, #ifdef _WIN32 errcode = GetLastError(); - - sock_fmterror("send(): ", errcode, errbuf, errbuflen); - if (errcode == WSAECONNRESET) + if (errcode == WSAECONNRESET || + errcode == WSAECONNABORTED) + { + /* + * WSAECONNABORTED appears to be the error + * returned in Winsock when you try to send + * on a connection where the peer has closed + * the receive side. + */ return -2; + } + sock_fmterror("send(): ", errcode, errbuf, errbuflen); #else errcode = errno; - sock_fmterror("send(): ", errcode, errbuf, errbuflen); - if (errcode == ECONNRESET) + if (errcode == ECONNRESET || errcode == EPIPE) + { + /* + * EPIPE is what's returned on UN*X when + * you try to send on a connection when + * the peer has closed the receive side. + */ return -2; + } + sock_fmterror("send(): ", errcode, errbuf, errbuflen); #endif return -1; } |