From: Kurt Zeilenga Date: Thu, 10 Jun 1999 21:11:21 +0000 (+0000) Subject: Add cheap EBADF loop protection. X-Git-Tag: OPENLDAP_REL_ENG_2_BP~346 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=571e8c098d01ebf3c9f714dbccd7a100dd731004;p=openldap Add cheap EBADF loop protection. --- diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index b05cf793e0..2d3e8f9d6b 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -295,6 +295,8 @@ slapd_daemon_task( while ( !slapd_shutdown ) { unsigned int i; int ns, nfds; + int ebadf = 0; +#define SLAPD_EBADF_LIMIT 10 fd_set readfds; fd_set writefds; @@ -360,7 +362,11 @@ slapd_daemon_task( case -1: { /* failure - try again */ int err = errno; - if( err != EINTR || err != EBADF) { + if( err == EBADF && ++ebadf < SLAPD_EBADF_LIMIT) { + continue; + } + + if( err != EINTR ) { Debug( LDAP_DEBUG_CONNS, "daemon: select failed (%d): %s\n", err, @@ -374,12 +380,14 @@ slapd_daemon_task( continue; case 0: /* timeout - let threads run */ + ebadf = 0; Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n", 0, 0, 0 ); ldap_pvt_thread_yield(); continue; default: /* something happened - deal with it */ + ebadf = 0; Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n", ns, 0, 0 ); /* FALL THRU */