X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fconnection.c;h=c64ef4866ed2ffadf5d3398636c49ac6894fdbc3;hb=b60644a07fc620d8e1f367e828355e6babc8d44f;hp=ddaddd1a6089d9aefe7e6b7c6deb866183793cb3;hpb=0b29856b16deba9e26f2a8b8c42bb87073516b00;p=openldap diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index ddaddd1a60..c64ef4866e 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -196,23 +196,22 @@ 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; + if( connections[i].c_struct_state != SLAP_C_UNINITIALIZED ) { + ldap_pvt_thread_mutex_lock( &connections[i].c_mutex ); + if( connections[i].c_struct_state == SLAP_C_USED ) { + + /* 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 ); + } else { + /* c_mutex is locked */ + connection_closing( &connections[i], "slapd shutdown" ); + connection_close( &connections[i] ); + } + } + ldap_pvt_thread_mutex_unlock( &connections[i].c_mutex ); } - - ldap_pvt_thread_mutex_lock( &connections[i].c_mutex ); - - /* c_mutex is locked */ - connection_closing( &connections[i], "slapd shutdown" ); - connection_close( &connections[i] ); - - ldap_pvt_thread_mutex_unlock( &connections[i].c_mutex ); } return 0; @@ -306,10 +305,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 */ @@ -1751,6 +1750,9 @@ static int connection_bind_cleanup_cb( Operation *op, SlapReply *rs ) { op->o_conn->c_sasl_bindop = NULL; + ch_free( op->o_callback ); + op->o_callback = NULL; + return SLAP_CB_CONTINUE; }