]> git.sur5r.net Git - openldap/commitdiff
Add cheap EBADF loop protection.
authorKurt Zeilenga <kurt@openldap.org>
Thu, 10 Jun 1999 21:11:21 +0000 (21:11 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 10 Jun 1999 21:11:21 +0000 (21:11 +0000)
servers/slapd/daemon.c

index b05cf793e0e17d1d120b4ba19ec6a21558c2230f..2d3e8f9d6b2b767272a561c4a5a3876344793768 100644 (file)
@@ -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 */