From 098153c5bba471a8cfe69aa3d7a1f135a80b26ca Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 17 Aug 2006 00:44:38 +0000 Subject: [PATCH] Move socket close into slapd_remove, don't close until after socket is removed from daemon control. --- servers/slapd/connection.c | 5 ++++- servers/slapd/daemon.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index f067714cd8..8a2fc55c10 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -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( ); diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index d437d1dbca..b84d7c5caa 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -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. -- 2.39.5