From eda428dc7ff65cc1e617b7619ced8a1854244c75 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 16 Oct 2014 09:21:41 +1100 Subject: [PATCH] Handle potentially recoverable errors in accept() to allow us to share the fd in future --- src/connector.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/connector.c b/src/connector.c index 7a3bd108..5be43465 100644 --- a/src/connector.c +++ b/src/connector.c @@ -97,6 +97,12 @@ static int accept_client(conn_instance_t *ci) address_len = sizeof(client->address); fd = accept(ci->serverfd, &client->address, &address_len); if (unlikely(fd < 0)) { + /* Handle these errors gracefully should we ever share this + * socket */ + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ECONNABORTED || errno == EINTR) { + LOGERR("Recoverable error on accept in accept_client"); + return 0; + } LOGERR("Failed to accept on socket %d in acceptor", ci->serverfd); dealloc(client); return -1;