From: Howard Chu Date: Thu, 18 Nov 2004 19:29:24 +0000 (+0000) Subject: shutdown on failure in epoll_ctl when adding a socket... X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~275 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fb7a5d7a55b4ec7596c1ee6747d9176a72a76273;p=openldap shutdown on failure in epoll_ctl when adding a socket... --- diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 5094345e99..6b3bf4174c 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -137,7 +137,7 @@ static struct slap_daemon { epoll_ctl(slap_daemon.sd_epfd, EPOLL_CTL_MOD, s, \ &SLAP_SOCK_EP(s)); \ } \ -} while(0) \ +} while(0) #define SLAP_SOCK_SET_READ(s) SLAP_SET_SOCK(s, EPOLLIN) #define SLAP_SOCK_SET_WRITE(s) SLAP_SET_SOCK(s, EPOLLOUT) @@ -152,7 +152,8 @@ static struct slap_daemon { /* If a Listener address is provided, store that as the epoll data. * Otherwise, store the address of this socket's slot in the - * index array. + * index array. If we can't do this add, the system is out of + * resources and we need to shutdown. */ #define SLAP_ADD_SOCK(s, l) do { \ int rc; \ @@ -162,6 +163,11 @@ static struct slap_daemon { rc = epoll_ctl(slap_daemon.sd_epfd, EPOLL_CTL_ADD, s, \ &SLAP_SOCK_EP(s)); \ if ( rc == 0 ) slap_daemon.sd_nfds++; \ + else { + Debug( LDAP_DEBUG_ANY, "daemon: epoll_ctl ADD failed, errno %d, shutting down\n" + errno, 0, 0 ); + slapd_shutdown = 2; \ + } } while(0) #define SLAP_EV_LISTENER(ptr) (((int *)(ptr) >= slap_daemon.sd_index && \