mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
In connections_shutdown - check for Uninitialized struct first, since
attempting to lock an unint'd mutex may crash on some platforms. And there is no chance for an unint'd conn to get init'd while shutdown is occurring, so the unprotected check of struct state is safe.
This commit is contained in:
parent
758f4d8154
commit
df54b1a244
@ -196,20 +196,22 @@ int connections_shutdown(void)
|
||||
ber_socket_t i;
|
||||
|
||||
for ( i = 0; i < dtblsize; i++ ) {
|
||||
ldap_pvt_thread_mutex_lock( &connections[i].c_mutex );
|
||||
if( connections[i].c_struct_state == SLAP_C_USED ) {
|
||||
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] );
|
||||
/* 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_unlock( &connections[i].c_mutex );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user