]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/daemon.c
Fix negative caching again, be sure it's really from zero entries returned
[openldap] / servers / slapd / daemon.c
index dbfcd43cbe066f80bc2b8007dbfbe3be4e8afa71..01afde3584a627ca43555ba44ee399911f7e5fc9 100644 (file)
@@ -82,11 +82,19 @@ static ber_socket_t wake_sds[2];
 static int emfile;
 
 static volatile int waking;
+#ifdef NO_THREADS
 #define WAKE_LISTENER(w)       do { \
        if ((w) && ++waking < 5) { \
                tcp_write( wake_sds[1], "0", 1 ); \
        } \
 } while(0)
+#else
+#define WAKE_LISTENER(w)       do { \
+       if (w) { \
+               tcp_write( wake_sds[1], "0", 1 ); \
+       } \
+} while(0)
+#endif
 
 volatile sig_atomic_t slapd_shutdown = 0;
 volatile sig_atomic_t slapd_gentle_shutdown = 0;
@@ -1113,6 +1121,12 @@ int slapd_daemon_init( const char *urls )
 
        Debug( LDAP_DEBUG_ARGS, "daemon_init: %s\n",
                urls ? urls : "<null>", 0, 0 );
+
+       ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex );
+#ifdef HAVE_TCPD
+       ldap_pvt_thread_mutex_init( &slap_daemon.tcpd_mutex );
+#endif
+
        if( (rc = sockinit()) != 0 ) return rc;
 
 #ifdef HAVE_SYSCONF
@@ -1182,11 +1196,6 @@ int slapd_daemon_init( const char *urls )
 #endif
 
        ldap_charray_free( u );
-       ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex );
-
-#ifdef HAVE_TCPD
-       ldap_pvt_thread_mutex_init( &slap_daemon.tcpd_mutex );
-#endif
 
        return !i;
 }
@@ -1832,21 +1841,17 @@ slapd_daemon_task(
                case -1: {      /* failure - try again */
                                int err = sock_errno();
 
-                               if( err == EBADF
-#ifdef WSAENOTSOCK
-                                       /* you'd think this would be EBADF */
-                                       || err == WSAENOTSOCK
-#endif
-                               ) {
-                                       if (++ebadf < SLAPD_EBADF_LIMIT)
-                                               continue;
-                               }
-
                                if( err != EINTR ) {
-                                       Debug( LDAP_DEBUG_CONNS,
-                                               "daemon: select failed (%d): %s\n",
-                                               err, sock_errstr(err), 0 );
-                                       slapd_shutdown = 2;
+                                       ebadf++;
+
+                                       /* Don't log unless we got it twice in a row */
+                                       if ( !( ebadf & 1 )) {
+                                               Debug( LDAP_DEBUG_ANY,
+                                                       "daemon: select failed count %d err (%d): %s\n",
+                                                       ebadf, err, sock_errstr(err) );
+                                       }
+                                       if ( ebadf >= SLAPD_EBADF_LIMIT )
+                                               slapd_shutdown = 2;
                                }
                        }
                        continue;