Commit b52c62e6 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

don't assert on unprotected data (ITS#5814)

parent 8726452d
...@@ -424,7 +424,9 @@ Connection * connection_init( ...@@ -424,7 +424,9 @@ Connection * connection_init(
if ( flags & CONN_IS_CLIENT ) { if ( flags & CONN_IS_CLIENT ) {
c->c_connid = 0; c->c_connid = 0;
c->c_conn_state = SLAP_C_CLIENT; c->c_conn_state = SLAP_C_CLIENT;
ldap_pvt_thread_mutex_lock( &connections_mutex );
c->c_struct_state = SLAP_C_USED; c->c_struct_state = SLAP_C_USED;
ldap_pvt_thread_mutex_unlock( &connections_mutex );
c->c_close_reason = "?"; /* should never be needed */ c->c_close_reason = "?"; /* should never be needed */
ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_FD, &sfd ); ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_FD, &sfd );
ldap_pvt_thread_mutex_unlock( &c->c_mutex ); ldap_pvt_thread_mutex_unlock( &c->c_mutex );
...@@ -509,7 +511,9 @@ Connection * connection_init( ...@@ -509,7 +511,9 @@ Connection * connection_init(
ldap_pvt_thread_mutex_unlock( &conn_nextid_mutex ); ldap_pvt_thread_mutex_unlock( &conn_nextid_mutex );
c->c_conn_state = SLAP_C_INACTIVE; c->c_conn_state = SLAP_C_INACTIVE;
ldap_pvt_thread_mutex_lock( &connections_mutex );
c->c_struct_state = SLAP_C_USED; c->c_struct_state = SLAP_C_USED;
ldap_pvt_thread_mutex_unlock( &connections_mutex );
c->c_close_reason = "?"; /* should never be needed */ c->c_close_reason = "?"; /* should never be needed */
c->c_ssf = c->c_transport_ssf = ssf; c->c_ssf = c->c_transport_ssf = ssf;
...@@ -843,12 +847,12 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) ...@@ -843,12 +847,12 @@ Connection* connection_next( Connection *c, ber_socket_t *index )
for(; *index < dtblsize; (*index)++) { for(; *index < dtblsize; (*index)++) {
int c_struct; int c_struct;
if( connections[*index].c_struct_state == SLAP_C_UNINITIALIZED ) { if( connections[*index].c_struct_state == SLAP_C_UNINITIALIZED ) {
/* FIXME: accessing c_conn_state without locking c_mutex */
assert( connections[*index].c_conn_state == SLAP_C_INVALID ); assert( connections[*index].c_conn_state == SLAP_C_INVALID );
continue; continue;
} }
if( connections[*index].c_struct_state == SLAP_C_USED ) { if( connections[*index].c_struct_state == SLAP_C_USED ) {
assert( connections[*index].c_conn_state != SLAP_C_INVALID );
c = &connections[(*index)++]; c = &connections[(*index)++];
if ( ldap_pvt_thread_mutex_trylock( &c->c_mutex )) { if ( ldap_pvt_thread_mutex_trylock( &c->c_mutex )) {
/* avoid deadlock */ /* avoid deadlock */
...@@ -861,6 +865,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) ...@@ -861,6 +865,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index )
continue; continue;
} }
} }
assert( c->c_conn_state != SLAP_C_INVALID );
break; break;
} }
...@@ -868,6 +873,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) ...@@ -868,6 +873,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index )
if ( c_struct == SLAP_C_PENDING ) if ( c_struct == SLAP_C_PENDING )
continue; continue;
assert( c_struct == SLAP_C_UNUSED ); assert( c_struct == SLAP_C_UNUSED );
/* FIXME: accessing c_conn_state without locking c_mutex */
assert( connections[*index].c_conn_state == SLAP_C_INVALID ); assert( connections[*index].c_conn_state == SLAP_C_INVALID );
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment