From 123c0f5387ecef287dd11f4dc790fb76ee1c0f67 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sat, 7 Apr 2012 19:19:06 +0200 Subject: Handle insufficient resources on accept() decently If accept() call fails due to insuffient OS resources the new connection is rejected. Signed-off-by: Martin Sustrik --- src/ipc_listener.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ipc_listener.cpp') diff --git a/src/ipc_listener.cpp b/src/ipc_listener.cpp index b3e5693..743ca86 100644 --- a/src/ipc_listener.cpp +++ b/src/ipc_listener.cpp @@ -151,12 +151,15 @@ int xs::ipc_listener_t::close () xs::fd_t xs::ipc_listener_t::accept () { // Accept one connection and deal with different failure modes. + // The situation where connection cannot be accepted due to insufficient + // resources is considered valid and treated by ignoring the connection. xs_assert (s != retired_fd); fd_t sock = ::accept (s, NULL, NULL); if (sock == -1) { errno_assert (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR || errno == ECONNABORTED || errno == EPROTO || - errno == ENOBUFS); + errno == ENOBUFS || errno == ENOMEM || errno == EMFILE || + errno == ENFILE); return retired_fd; } return sock; -- cgit v1.2.3