From: Kurt Zeilenga Date: Thu, 27 May 1999 06:22:59 +0000 (+0000) Subject: move connection_close call from connection_input to connection_resched X-Git-Tag: OPENLDAP_REL_ENG_2_BP~507 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2d1cf97a5699c2eaa632b1b37c3317804c8c0169;p=openldap move connection_close call from connection_input to connection_resched to avoid accessing c_conn_state after close. --- diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 2293b216f8..126b4b6d21 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -125,8 +125,11 @@ int connections_shutdown(void) } ldap_pvt_thread_mutex_lock( &connections[i].c_mutex ); + + /* connections_mutex and c_mutex are locked */ connection_closing( &connections[i] ); connection_close( &connections[i] ); + ldap_pvt_thread_mutex_unlock( &connections[i].c_mutex ); } @@ -620,6 +623,7 @@ connection_operation( void *arg_v ) case LDAP_REQ_UNBIND_30: #endif case LDAP_REQ_UNBIND: + /* c_mutex is locked */ connection_closing( conn ); break; @@ -629,14 +633,6 @@ connection_operation( void *arg_v ) } } - if( conn->c_conn_state == SLAP_C_CLOSING ) { - Debug( LDAP_DEBUG_TRACE, - "connection_operation: attempting closing conn=%ld sd=%d.\n", - conn->c_connid, ber_pvt_sb_get_desc( conn->c_sb ), 0 ); - - connection_close( conn ); - } - ldap_pvt_thread_mutex_lock( &active_threads_mutex ); active_threads--; if( active_threads < 1 ) { @@ -659,7 +655,9 @@ int connection_read(int s) ldap_pvt_thread_mutex_lock( &connections_mutex ); + /* get (locked) connection */ c = connection_get( s ); + if( c == NULL ) { Debug( LDAP_DEBUG_ANY, "connection_read(%d): no connection!\n", @@ -698,6 +696,7 @@ int connection_read(int s) "connection_read(%d): input error=%d id=%ld, closing.\n", s, rc, c->c_connid ); + /* connections_mutex and c_mutex are locked */ connection_closing( c ); connection_close( c ); } @@ -802,6 +801,15 @@ connection_resched( Connection *conn ) { Operation *op; + if( conn->c_conn_state == SLAP_C_CLOSING ) { + Debug( LDAP_DEBUG_TRACE, + "connection_resched: attempting closing conn=%ld sd=%d.\n", + conn->c_connid, ber_pvt_sb_get_desc( conn->c_sb ), 0 ); + + connection_close( conn ); + return 0; + } + if( conn->c_conn_state != SLAP_C_ACTIVE ) { /* other states need different handling */ return 0;