From 1d8cee1c70148ae0a905df1cc90acecc25ef92eb Mon Sep 17 00:00:00 2001 From: Quanah Gibson-Mount Date: Sat, 16 Dec 2006 01:40:11 +0000 Subject: [PATCH] Fix connections_shutdown(), protect assertion behind mutex --- servers/slapd/connection.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index b306f03667..fc0ebed127 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -196,22 +196,20 @@ int connections_shutdown(void) ber_socket_t i; for ( i = 0; i < dtblsize; i++ ) { - if( connections[i].c_struct_state != SLAP_C_USED ) { - continue; - } - /* give persistent clients a chance to cleanup */ - if( connections[i].c_conn_state == SLAP_C_CLIENT ) { - ldap_pvt_thread_pool_submit( &connection_pool, - connections[i].c_clientfunc, connections[i].c_clientarg ); - continue; - } - ldap_pvt_thread_mutex_lock( &connections[i].c_mutex ); + if( connections[i].c_struct_state == SLAP_C_USED ) { - /* c_mutex is locked */ - connection_closing( &connections[i], "slapd shutdown" ); - connection_close( &connections[i] ); - + /* give persistent clients a chance to cleanup */ + if( connections[i].c_conn_state == SLAP_C_CLIENT ) { + ldap_pvt_thread_pool_submit( &connection_pool, + connections[i].c_clientfunc, connections[i].c_clientarg ); + continue; + } else { + /* c_mutex is locked */ + connection_closing( &connections[i], "slapd shutdown" ); + connection_close( &connections[i] ); + } + } ldap_pvt_thread_mutex_unlock( &connections[i].c_mutex ); } @@ -306,10 +304,10 @@ static Connection* connection_get( ber_socket_t s ) if( c != NULL ) { ber_socket_t sd; - assert( c->c_struct_state != SLAP_C_UNINITIALIZED ); - ldap_pvt_thread_mutex_lock( &c->c_mutex ); + assert( c->c_struct_state != SLAP_C_UNINITIALIZED ); + ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_GET_FD, &sd ); if( c->c_struct_state != SLAP_C_USED ) { /* connection must have been closed due to resched */ -- 2.39.2