From: Kurt Zeilenga Date: Sun, 16 Oct 2005 00:17:58 +0000 (+0000) Subject: disable SLAP_SEM_LOAD_CONTROL by default, needs additional review/work X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~231 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=533394d64115685e24dcc88e81e006fa855ad966;p=openldap disable SLAP_SEM_LOAD_CONTROL by default, needs additional review/work Misc. other cleanup --- diff --git a/libraries/libldap_r/tpool.c b/libraries/libldap_r/tpool.c index bf8f908e56..dc1d683bc0 100644 --- a/libraries/libldap_r/tpool.c +++ b/libraries/libldap_r/tpool.c @@ -30,7 +30,7 @@ #include "ldap_thr_debug.h" /* May rename symbols defined below */ #ifdef LDAP_DEVEL -#define SLAP_SEM_LOAD_CONTROL +/* #define SLAP_SEM_LOAD_CONTROL /* must also be defined in slapd.h */ #endif #ifndef LDAP_THREAD_HAVE_TPOOL diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 25bd32f6a4..718744b95c 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -49,13 +49,13 @@ static ldap_pvt_thread_mutex_t* connections_mutex; static Connection **connections = NULL; -/* set to the number of processors */ +/* set to the number of processors (round up to a power of 2) */ # define NUM_CONNECTION_ARRAY 4 /* partition the array in a modulo manner */ # define MCA_conn_array_id(fd) ((int)(fd)%NUM_CONNECTION_ARRAY) # define MCA_conn_array_element_id(fd) ((int)(fd)/NUM_CONNECTION_ARRAY) -# define MCA_GET_CONNECTION(fd) (&(connections[MCA_conn_array_id(fd)])\ +# define MCA_GET_CONNECTION(fd) (&(connections[MCA_conn_array_id(fd)]) \ [MCA_conn_array_element_id(fd)]) # define MCA_GET_CONN_MUTEX(fd) (&connections_mutex[MCA_conn_array_id(fd)]) @@ -137,26 +137,29 @@ int connections_init(void) return -1; } - connections_mutex = (ldap_pvt_thread_mutex_t*) ch_calloc( NUM_CONNECTION_ARRAY, sizeof(ldap_pvt_thread_mutex_t) ); + connections_mutex = (ldap_pvt_thread_mutex_t*) ch_calloc( + NUM_CONNECTION_ARRAY, sizeof(ldap_pvt_thread_mutex_t) ); if( connections_mutex == NULL ) { - Debug( LDAP_DEBUG_ANY, - "connections_init: allocation of connection mutex[%d] failed\n", i, 0, 0 ); + Debug( LDAP_DEBUG_ANY, "connections_init: " + "allocation of connection mutex[%d] failed\n", i, 0, 0 ); return -1; } - connections = (Connection**) ch_calloc( NUM_CONNECTION_ARRAY, sizeof(Connection*)); + connections = (Connection**) ch_calloc( + NUM_CONNECTION_ARRAY, sizeof(Connection*)); if( connections == NULL ) { - Debug( LDAP_DEBUG_ANY, - "connections_init: allocation of connection[%d] failed\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_ANY, "connections_init: " + "allocation of connection[%d] failed\n", 0, 0, 0 ); return -1; } for ( i = 0; i < NUM_CONNECTION_ARRAY; i++ ) { ldap_pvt_thread_mutex_init( connections_mutex+i ); - connections[i] = (Connection*) ch_calloc( (dtblsize/NUM_CONNECTION_ARRAY), sizeof(Connection) ); + connections[i] = (Connection*) ch_calloc( + dtblsize/NUM_CONNECTION_ARRAY, sizeof(Connection) ); if( connections[i] == NULL ) { - Debug( LDAP_DEBUG_ANY, - "connections_init: allocation (%d*%ld) of connection array[%d] failed\n", + Debug( LDAP_DEBUG_ANY, "connections_init: " + "allocation (%d*%ld) of connection array[%d] failed\n", dtblsize, (long) sizeof(Connection), i ); return -1; } @@ -166,7 +169,8 @@ int connections_init(void) ldap_pvt_thread_mutex_init( &conn_nextid_mutex ); assert( connections[0]->c_struct_state == SLAP_C_UNINITIALIZED ); - assert( connections[NUM_CONNECTION_ARRAY-1]->c_struct_state == SLAP_C_UNINITIALIZED ); + assert( connections[NUM_CONNECTION_ARRAY-1]->c_struct_state == + SLAP_C_UNINITIALIZED ); for ( i = 0; i < NUM_CONNECTION_ARRAY; i++ ) { conn = connections[i]; @@ -201,8 +205,8 @@ int connections_init(void) connections = (Connection *) ch_calloc( dtblsize, sizeof(Connection) ); if( connections == NULL ) { - Debug( LDAP_DEBUG_ANY, - "connections_init: allocation (%d*%ld) of connection array failed\n", + Debug( LDAP_DEBUG_ANY, "connections_init: " + "allocation (%d*%ld) of connection array failed\n", dtblsize, (long) sizeof(Connection), 0 ); return -1; } @@ -386,8 +390,9 @@ int connections_timeout_idle(time_t now) { /* Don't timeout a slow-running request or a persistent * outbound connection */ - if( c->c_n_ops_executing || - c->c_conn_state == SLAP_C_CLIENT ) continue; + if( c->c_n_ops_executing || c->c_conn_state == SLAP_C_CLIENT ) { + continue; + } if( difftime( c->c_activitytime+global_idletimeout, now) < 0 ) { /* close it */ @@ -413,9 +418,7 @@ static Connection* connection_get( ber_socket_t s ) assert( connections != NULL ); - if(s == AC_SOCKET_INVALID) { - return NULL; - } + if(s == AC_SOCKET_INVALID) return NULL; #ifndef HAVE_WINSOCK c = MCA_GET_CONNECTION(s); @@ -564,9 +567,7 @@ long connection_init( break; } - if( connections[i].c_conn_state == SLAP_C_CLIENT ) { - continue; - } + if( connections[i].c_conn_state == SLAP_C_CLIENT ) continue; assert( connections[i].c_struct_state == SLAP_C_USED ); assert( connections[i].c_conn_state != SLAP_C_INVALID ); @@ -1028,9 +1029,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) assert( index != NULL ); assert( *index <= (dtblsize/NUM_CONNECTION_ARRAY) ); - if( c != NULL ) { - ldap_pvt_thread_mutex_unlock( &c->c_mutex ); - } + if( c != NULL ) ldap_pvt_thread_mutex_unlock( &c->c_mutex ); c = NULL; @@ -1056,9 +1055,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) assert( conn->c_conn_state == SLAP_C_INVALID ); } - if( c != NULL ) { - ldap_pvt_thread_mutex_lock( &c->c_mutex ); - } + if( c != NULL ) ldap_pvt_thread_mutex_lock( &c->c_mutex ); return c; @@ -1069,9 +1066,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) assert( index != NULL ); assert( *index <= dtblsize ); - if( c != NULL ) { - ldap_pvt_thread_mutex_unlock( &c->c_mutex ); - } + if( c != NULL ) ldap_pvt_thread_mutex_unlock( &c->c_mutex ); c = NULL; @@ -1095,10 +1090,7 @@ Connection* connection_next( Connection *c, ber_socket_t *index ) assert( connections[*index].c_conn_state == SLAP_C_INVALID ); } - if( c != NULL ) { - ldap_pvt_thread_mutex_lock( &c->c_mutex ); - } - + if( c != NULL ) ldap_pvt_thread_mutex_lock( &c->c_mutex ); return c; } #endif @@ -1111,9 +1103,7 @@ void connection_done( Connection *c ) assert( connections != NULL ); - if( c != NULL ) { - ldap_pvt_thread_mutex_unlock( &c->c_mutex ); - } + if( c != NULL ) ldap_pvt_thread_mutex_unlock( &c->c_mutex ); #ifdef SLAP_MULTI_CONN_ARRAY for ( conn_array_id = 0; @@ -1311,10 +1301,11 @@ operations_error: } if ( op->o_cancel == SLAP_CANCEL_REQ ) { - if ( rc == SLAPD_ABANDON ) + if ( rc == SLAPD_ABANDON ) { op->o_cancel = SLAP_CANCEL_ACK; - else + } else { op->o_cancel = LDAP_TOO_LATE; + } } while ( op->o_cancel != SLAP_CANCEL_NONE && op->o_cancel != SLAP_CANCEL_DONE ) @@ -1336,8 +1327,8 @@ operations_error: case LBER_ERROR: case LDAP_REQ_UNBIND: /* c_mutex is locked */ - connection_closing( - conn, tag == LDAP_REQ_UNBIND ? NULL : "operations error" ); + connection_closing( conn, + tag == LDAP_REQ_UNBIND ? NULL : "operations error" ); break; case LDAP_REQ_BIND: diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 10749c3c95..03059b2719 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -61,8 +61,8 @@ LDAP_BEGIN_DECL #ifdef LDAP_DEVEL #define SLAP_LIGHTWEIGHT_DISPATCHER /* experimental slapd architecture */ -#define SLAP_SEM_LOAD_CONTROL /* must also be defined in libldap_r/tpool.c */ #define SLAP_MULTI_CONN_ARRAY +/* #define SLAP_SEM_LOAD_CONTROL /* must also be defined in libldap_r/tpool.c */ #define SLAP_ACL_HONOR_DISCLOSE /* partially implemented */ #define SLAP_ACL_HONOR_MANAGE /* not yet implemented */