]> git.sur5r.net Git - openldap/commitdiff
Cleanup, fix ITS#4120
authorHoward Chu <hyc@openldap.org>
Sat, 29 Oct 2005 02:06:32 +0000 (02:06 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 29 Oct 2005 02:06:32 +0000 (02:06 +0000)
servers/slapd/connection.c
servers/slapd/daemon.c

index 89de750871e83e2aba75a4f7e428cbdee03ee68a..eb7dd474edb7c3ef9a43f476b42d3483dc2a5857 100644 (file)
@@ -1407,7 +1407,7 @@ static void* connection_read_thread( void* ctx, void* argv )
 {
        int rc ;
        Operation* new_op = NULL;
-       ber_socket_t s = (ber_socket_t)argv;
+       ber_socket_t s = (long)argv;
 
        /*
         * read incoming LDAP requests. If there is more than one,
@@ -1416,16 +1416,16 @@ static void* connection_read_thread( void* ctx, void* argv )
        if( ( rc = connection_read( s, &new_op ) ) < 0 ) {
                Debug( LDAP_DEBUG_TRACE, "connection_read(%d) error\n", s, 0, 0 );
                tcp_close( s );
-               return (void*)rc;
+               return (void*)(long)rc;
        }
 
        /* execute the queued request in the same thread */
        if( new_op ) {
-               rc = (int)connection_operation(
+               rc = (long)connection_operation(
                        ldap_pvt_thread_pool_context(), new_op );
        }
 
-       return (void*)rc;
+       return (void*)(long)rc;
 }
 
 int connection_read_activate( ber_socket_t s )
@@ -1440,7 +1440,7 @@ int connection_read_activate( ber_socket_t s )
        slapd_clr_read( s, 0 );
 
        rc = ldap_pvt_thread_pool_submit( &connection_pool,
-               connection_read_thread, (void *) s );
+               connection_read_thread, (void *)(long)s );
 
        if( rc != 0 ) {
                Debug( LDAP_DEBUG_ANY,
@@ -2036,6 +2036,12 @@ static int connection_op_activate( Operation *op )
 }
 
 #ifdef SLAP_LIGHTWEIGHT_DISPATCHER
+static int connection_write( ber_socket_t s );
+static void *connection_write_thread( void *ctx, void *arg )
+{
+       return (void *)(long)connection_write((long)arg);
+}
+
 int connection_write_activate( ber_socket_t s )
 {
        int rc;
@@ -2045,18 +2051,14 @@ int connection_write_activate( ber_socket_t s )
         * thread write data on it. Otherwise the listener thread will repeatedly
         * submit the same event on it to the pool.
         */
-
-#ifndef SLAP_LIGHTWEIGHT_DISPATCHER
        slapd_clr_write( s, 0);
-       c->c_n_write++;
-#endif
 
        rc = ldap_pvt_thread_pool_submit( &connection_pool,
-               connection_read_thread, (void *) s );
+               connection_write_thread, (void *)(long)s );
 
        if( rc != 0 ) {
                Debug( LDAP_DEBUG_ANY,
-                       "connection_write_activiate(%d): submit failed (%d)\n",
+                       "connection_write_activate(%d): submit failed (%d)\n",
                        (int) s, rc, 0 );
        }
        return rc;
@@ -2085,8 +2087,8 @@ int connection_write(ber_socket_t s)
 
 #ifndef SLAP_LIGHTWEIGHT_DISPATCHER
        slapd_clr_write( s, 0);
-       c->c_n_write++;
 #endif
+       c->c_n_write++;
 
        Debug( LDAP_DEBUG_TRACE,
                "connection_write(%d): waking output for id=%lu\n",
index ed6078081b11c201caa9560393ee6651ddd38548..0c59f3c89c779031a283a31f5232fdf527171c94 100644 (file)
@@ -1711,13 +1711,11 @@ slapd_daemon_task(
                        }
                }
 #endif
-
                at = 0;
 
                ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
 
                nwriters = slap_daemon.sd_nwriters;
-               SLAP_EVENT_INIT;
 
                for ( l = 0; slap_listeners[l] != NULL; l++ ) {
                        Listener *lr = slap_listeners[l];
@@ -1731,6 +1729,8 @@ slapd_daemon_task(
                        }
                }
 
+               SLAP_EVENT_INIT;
+
                nfds = SLAP_EVENT_MAX;
 
                if ( global_idletimeout && slap_daemon.sd_nactives ) at = 1;
@@ -1954,7 +1954,7 @@ slapd_daemon_task(
                        /*
                         * NOTE: it is possible that the connection was closed
                         * and that the stream is now inactive.
-                        * connection_write() must validitate the stream is still
+                        * connection_write() must validate the stream is still
                         * active.
                         */
                        if ( connection_write( wd ) < 0 ) {