]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/daemon.c
allow empty modlist
[openldap] / servers / slapd / daemon.c
index 85fbf5f3d8053968c63b11376df56223686871bd..4f6875ff78ef79ebd5db8ba05065a56aa4ca3367 100644 (file)
@@ -1121,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
@@ -1151,6 +1157,8 @@ int slapd_daemon_init( const char *urls )
        if( u == NULL || u[0] == NULL ) {
                Debug( LDAP_DEBUG_ANY, "daemon_init: no urls (%s) provided.\n",
                        urls, 0, 0 );
+               if ( u )
+                       ldap_charray_free( u );
                return -1;
        }
 
@@ -1190,11 +1198,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;
 }
@@ -1976,9 +1979,6 @@ slapd_daemon_task(
                                "daemon: write active on %d\n",
                                wd, 0, 0 );
 
-#ifdef SLAP_LIGHTWEIGHT_DISPATCHER
-                       connection_write_activate( wd );
-#else
                        /*
                         * NOTE: it is possible that the connection was closed
                         * and that the stream is now inactive.
@@ -1994,7 +1994,6 @@ slapd_daemon_task(
                                        nrfds--;
                                }
                        }
-#endif
                }
 
                for ( i = 0; nrfds > 0; i++ ) {
@@ -2070,7 +2069,7 @@ slapd_daemon_task(
 #endif
 
                for (i=0; i<ns; i++) {
-                       int rc = 1, fd;
+                       int rc = 1, fd, waswrite = 0;
 
                        if ( SLAP_EVENT_IS_LISTENER(i) ) {
 #ifdef SLAP_LIGHTWEIGHT_DISPATCHER
@@ -2100,9 +2099,8 @@ slapd_daemon_task(
                                                "daemon: write active on %d\n",
                                                fd, 0, 0 );
 
-#ifdef SLAP_LIGHTWEIGHT_DISPATCHER
-                                       connection_write_activate( fd );
-#else
+                                       waswrite = 1;
+
                                        /*
                                         * NOTE: it is possible that the connection was closed
                                         * and that the stream is now inactive.
@@ -2112,9 +2110,9 @@ slapd_daemon_task(
                                        if ( connection_write( fd ) < 0 ) {
                                                continue;
                                        }
-#endif
                                }
-                               if( SLAP_EVENT_IS_READ( i ) ) {
+                               /* If event is a read or an error */
+                               if( SLAP_EVENT_IS_READ( i ) || !waswrite ) {
                                        Debug( LDAP_DEBUG_CONNS,
                                                "daemon: read active on %d\n",
                                                fd, 0, 0 );