]> git.sur5r.net Git - openldap/commitdiff
Move socket close into slapd_remove, don't close until after socket
authorHoward Chu <hyc@openldap.org>
Thu, 17 Aug 2006 00:44:38 +0000 (00:44 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 17 Aug 2006 00:44:38 +0000 (00:44 +0000)
is removed from daemon control.

servers/slapd/connection.c
servers/slapd/daemon.c

index f067714cd8c88df9bbec81537856ada270d3f853..8a2fc55c10b4d3293a0b55db83a377d7ca48a59f 100644 (file)
@@ -653,7 +653,7 @@ void connection2anonymous( Connection *c )
 static void
 connection_destroy( Connection *c )
 {
-       ber_socket_t    sd;
+       ber_socket_t    sd, inval = AC_SOCKET_INVALID;
        unsigned long   connid;
        const char              *close_reason;
        Sockbuf                 *sb;
@@ -733,6 +733,7 @@ connection_destroy( Connection *c )
        ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
        slapd_sd_lock();
 
+       ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_FD, &inval );
        ber_sockbuf_free( sb );
 
        /* c must be fully reset by this point; when we call slapd_remove
@@ -1218,6 +1219,7 @@ void connection_client_stop(
        ber_socket_t s )
 {
        Connection *c;
+       ber_socket_t inval = AC_SOCKET_INVALID;
 
        /* get (locked) connection */
        c = connection_get( s );
@@ -1229,6 +1231,7 @@ void connection_client_stop(
        c->c_struct_state = SLAP_C_UNUSED;
        c->c_close_reason = "?";                        /* should never be needed */
        slapd_sd_lock();
+       ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_FD, &inval );
        ber_sockbuf_free( c->c_sb );
        slapd_remove( s, 0, 1, 1 );
        c->c_sb = ber_sockbuf_alloc( );
index d437d1dbca6e8703ad4d8af12b3c35ef3597da1e..b84d7c5caaee3ac9f14f98749228577abb613dcb 100644 (file)
@@ -527,6 +527,8 @@ void slapd_remove(
 
        SLAP_DEL_SOCK(s);
 
+       tcp_close(s);
+
        /* If we ran out of file descriptors, we dropped a listener from
         * the select() loop. Now that we're removing a session from our
         * control, we can try to resume a dropped listener to use.