Skip to content
Snippets Groups Projects
Commit 2d1cf97a authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

move connection_close call from connection_input to connection_resched

to avoid accessing c_conn_state after close.
parent 549dd296
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment