]> git.sur5r.net Git - openldap/commitdiff
Move ber_sockbuf_free() to slapd_remove() to avoid using AC_SOCKET_INVALID
authorHoward Chu <hyc@openldap.org>
Fri, 18 Aug 2006 23:54:24 +0000 (23:54 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 18 Aug 2006 23:54:24 +0000 (23:54 +0000)
servers/slapd/connection.c
servers/slapd/daemon.c
servers/slapd/proto-slap.h

index e9e60db17c687ad972bbe0eb33db695e95eec51e..16433b2533a052bbcc1c608fb96c377047dcae5f 100644 (file)
@@ -653,7 +653,7 @@ void connection2anonymous( Connection *c )
 static void
 connection_destroy( Connection *c )
 {
-       ber_socket_t    sd, inval = AC_SOCKET_INVALID;
+       ber_socket_t    sd;
        unsigned long   connid;
        const char              *close_reason;
        Sockbuf                 *sb;
@@ -731,23 +731,17 @@ connection_destroy( Connection *c )
        }
 
        ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );
-       slapd_sd_lock();
-
-       ber_sockbuf_ctrl( sb, LBER_SB_OPT_SET_FD, &inval );
-       ber_sockbuf_free( sb );
 
        /* c must be fully reset by this point; when we call slapd_remove
         * it may get immediately reused by a new connection.
         */
        if ( sd != AC_SOCKET_INVALID ) {
-               slapd_remove( sd, 1, 0, 1 );
+               slapd_remove( sd, sb, 1, 0, 0 );
 
                Statslog( LDAP_DEBUG_STATS, (close_reason
                                                                         ? "conn=%lu fd=%ld closed (%s)\n"
                                                                         : "conn=%lu fd=%ld closed\n"),
                        connid, (long) sd, close_reason, 0, 0 );
-       } else {
-               slapd_sd_unlock();
        }
 }
 
@@ -1219,7 +1213,7 @@ void connection_client_stop(
        ber_socket_t s )
 {
        Connection *c;
-       ber_socket_t inval = AC_SOCKET_INVALID;
+       Sockbuf *sb;
 
        /* get (locked) connection */
        c = connection_get( s );
@@ -1230,15 +1224,13 @@ void connection_client_stop(
        c->c_conn_state = SLAP_C_INVALID;
        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 );
+       sb = c->c_sb;
        c->c_sb = ber_sockbuf_alloc( );
        {
                ber_len_t max = sockbuf_max_incoming;
                ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
        }
+       slapd_remove( s, sb, 0, 1, 0 );
 
        connection_return( c );
 }
index b84d7c5caaee3ac9f14f98749228577abb613dcb..7e8dca9508ad45124967416f224779a63dc7f03c 100644 (file)
@@ -501,6 +501,7 @@ void slapd_sd_unlock()
  */
 void slapd_remove(
        ber_socket_t s,
+       Sockbuf *sb,
        int wasactive,
        int wake,
        int locked )
@@ -527,7 +528,7 @@ void slapd_remove(
 
        SLAP_DEL_SOCK(s);
 
-       tcp_close(s);
+       ber_sockbuf_free(sb);
 
        /* If we ran out of file descriptors, we dropped a listener from
         * the select() loop. Now that we're removing a session from our
index 99934a9f80b9664d59c55be93c770a888d274825..640fc982ce1b545f15184799dcfccad824928b75 100644 (file)
@@ -713,8 +713,8 @@ LDAP_SLAPD_F (int) slapd_daemon_init( const char *urls );
 LDAP_SLAPD_F (int) slapd_daemon_destroy(void);
 LDAP_SLAPD_F (int) slapd_daemon(void);
 LDAP_SLAPD_F (Listener **)     slapd_get_listeners LDAP_P((void));
-LDAP_SLAPD_F (void) slapd_remove LDAP_P((ber_socket_t s, int wasactive,
-       int wake, int locked ));
+LDAP_SLAPD_F (void) slapd_remove LDAP_P((ber_socket_t s, Sockbuf *sb,
+       int wasactive, int wake, int locked ));
 LDAP_SLAPD_F (void) slapd_sd_lock();
 LDAP_SLAPD_F (void) slapd_sd_unlock();