diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-10-24 00:55:18 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-10-24 00:55:18 +0000 |
commit | 5d53828c57e35cf1fa0e1d0c0ebc03d70502f731 (patch) | |
tree | aa9d0c89f1fa0acec80fe3368c53ca9280dd0965 /src/common/util.h | |
parent | 78a2c3aa3973a745a1742b4cd0a5cb99f650cdf0 (diff) | |
download | tor-5d53828c57e35cf1fa0e1d0c0ebc03d70502f731.tar.gz tor-5d53828c57e35cf1fa0e1d0c0ebc03d70502f731.zip |
Handle more errnos from accept() without closing the connection. This may fix a bug that could close OR listeners when (a) TCP connections were hung up before accept() could be called, or (b) during FD exhaustion.
svn:r2579
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h index 4d21f64bc1..e4f0eaec55 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -269,12 +269,22 @@ int parse_addr_and_port_range(const char *s, uint32_t *addr_out, /** Return true if e is EINPROGRESS or the local equivalent as returned by * a call to connect(). */ #define ERRNO_IS_CONN_EINPROGRESS(e) ((e) == WSAEINPROGRESS || (e)== WSAEINVAL) +/** Return true if e is EAGAIN or another error indicating that a call to + * accept() has no pending connections to return. */ +#define ERRNO_IS_ACCEPT_EAGAIN(e) ERRNO_IS_EAGAIN(e) +/** Return true if e is EMFILE or another error indicating that a call to + * accept() has failed because we're out of fds or something. */ +#define ERRNO_IS_ACCEPT_RESOURCE_LIMIT(e) \ + ((e) == WSAEMFILE || (e) == WSAENOBUFS) int tor_socket_errno(int sock); const char *tor_socket_strerror(int e); #else #define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN) #define ERRNO_IS_EINPROGRESS(e) ((e) == EINPROGRESS) #define ERRNO_IS_CONN_EINPROGRESS(e) ((e) == EINPROGRESS) +#define ERRNO_IS_ACCEPT_EAGAIN(e) ((e) == EAGAIN || (e) == ECONNABORTED) +#define ERRNO_IS_ACCEPT_RESOURCE_LIMIT(e) \ + ((e) == EMFILE || (e) == ENFILE || (e) == ENOBUFS || (e) == ENOMEM) #define tor_socket_errno(sock) (errno) #define tor_socket_strerror(e) strerror(e) #endif |