mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-07 14:18:15 +08:00
Thread error checking
This commit is contained in:
parent
1328777a85
commit
62a806b243
@ -35,7 +35,7 @@ upstream_connect_cb( evutil_socket_t s, short what, void *arg )
|
||||
int error = 0, rc = -1;
|
||||
epoch_t epoch;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
Debug( LDAP_DEBUG_CONNS, "upstream_connect_cb: "
|
||||
"fd=%d connection callback for backend uri='%s'\n",
|
||||
s, b->b_uri.bv_val );
|
||||
@ -55,7 +55,7 @@ upstream_connect_cb( evutil_socket_t s, short what, void *arg )
|
||||
goto done;
|
||||
}
|
||||
if ( error == EINTR || error == EINPROGRESS || error == EWOULDBLOCK ) {
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
epoch_leave( epoch );
|
||||
return;
|
||||
} else if ( error ) {
|
||||
@ -88,7 +88,7 @@ done:
|
||||
backend_retry( b );
|
||||
}
|
||||
preempted:
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
event_free( conn->event );
|
||||
ch_free( conn );
|
||||
@ -108,12 +108,12 @@ upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg )
|
||||
return;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
/* We were already running when backend_reset tried to cancel us, but were
|
||||
* already stuck waiting for the mutex, nothing to do and b_opening has
|
||||
* been decremented as well */
|
||||
if ( b->b_dns_req == NULL ) {
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
return;
|
||||
}
|
||||
b->b_dns_req = NULL;
|
||||
@ -182,7 +182,7 @@ upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg )
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
evutil_freeaddrinfo( res );
|
||||
epoch_leave( epoch );
|
||||
return;
|
||||
@ -194,7 +194,7 @@ fail:
|
||||
b->b_opening--;
|
||||
b->b_failed++;
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
if ( res ) {
|
||||
evutil_freeaddrinfo( res );
|
||||
}
|
||||
@ -206,9 +206,9 @@ backend_select( LloadOperation *op, int *res )
|
||||
{
|
||||
LloadBackend *b, *first, *next;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &backend_mutex );
|
||||
checked_lock( &backend_mutex );
|
||||
first = b = current_backend;
|
||||
ldap_pvt_thread_mutex_unlock( &backend_mutex );
|
||||
checked_unlock( &backend_mutex );
|
||||
|
||||
*res = LDAP_UNAVAILABLE;
|
||||
|
||||
@ -222,14 +222,14 @@ backend_select( LloadOperation *op, int *res )
|
||||
lload_c_head *head;
|
||||
LloadConnection *c;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
next = LDAP_CIRCLEQ_LOOP_NEXT( &backend, b, b_next );
|
||||
|
||||
if ( b->b_max_pending && b->b_n_ops_executing >= b->b_max_pending ) {
|
||||
Debug( LDAP_DEBUG_CONNS, "backend_select: "
|
||||
"backend %s too busy\n",
|
||||
b->b_uri.bv_val );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
b = next;
|
||||
*res = LDAP_BUSY;
|
||||
continue;
|
||||
@ -249,7 +249,7 @@ backend_select( LloadOperation *op, int *res )
|
||||
}
|
||||
|
||||
LDAP_CIRCLEQ_FOREACH ( c, head, c_next ) {
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
CONNECTION_LOCK(c);
|
||||
if ( c->c_state == LLOAD_C_READY && !c->c_pendingber &&
|
||||
( b->b_max_conn_pending == 0 ||
|
||||
@ -269,9 +269,9 @@ backend_select( LloadOperation *op, int *res )
|
||||
*/
|
||||
LDAP_CIRCLEQ_MAKE_TAIL( head, c, c_next );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &backend_mutex );
|
||||
checked_lock( &backend_mutex );
|
||||
current_backend = next;
|
||||
ldap_pvt_thread_mutex_unlock( &backend_mutex );
|
||||
checked_unlock( &backend_mutex );
|
||||
|
||||
b->b_n_ops_executing++;
|
||||
if ( op->o_tag == LDAP_REQ_BIND ) {
|
||||
@ -282,14 +282,14 @@ backend_select( LloadOperation *op, int *res )
|
||||
c->c_n_ops_executing++;
|
||||
c->c_counters.lc_ops_received++;
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
*res = LDAP_SUCCESS;
|
||||
return c;
|
||||
}
|
||||
CONNECTION_UNLOCK(c);
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
b = next;
|
||||
} while ( b != first );
|
||||
@ -370,7 +370,7 @@ backend_connect( evutil_socket_t s, short what, void *arg )
|
||||
char *hostname;
|
||||
epoch_t epoch;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
assert( b->b_dns_req == NULL );
|
||||
|
||||
if ( b->b_cookie ) {
|
||||
@ -381,7 +381,7 @@ backend_connect( evutil_socket_t s, short what, void *arg )
|
||||
Debug( LDAP_DEBUG_CONNS, "backend_connect: "
|
||||
"doing nothing, shutdown in progress\n" );
|
||||
b->b_opening--;
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ backend_connect( evutil_socket_t s, short what, void *arg )
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
epoch_leave( epoch );
|
||||
return;
|
||||
}
|
||||
@ -474,12 +474,12 @@ backend_connect( evutil_socket_t s, short what, void *arg )
|
||||
*/
|
||||
placeholder = (struct evdns_getaddrinfo_request *)&request;
|
||||
b->b_dns_req = placeholder;
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
request = evdns_getaddrinfo(
|
||||
dnsbase, hostname, NULL, &hints, upstream_name_cb, b );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
assert( request || b->b_dns_req != placeholder );
|
||||
|
||||
/* Record the request, unless upstream_name_cb or another thread
|
||||
@ -488,7 +488,7 @@ backend_connect( evutil_socket_t s, short what, void *arg )
|
||||
if ( b->b_dns_req == placeholder ) {
|
||||
b->b_dns_req = request;
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
epoch_leave( epoch );
|
||||
return;
|
||||
|
||||
@ -496,7 +496,7 @@ fail:
|
||||
b->b_opening--;
|
||||
b->b_failed++;
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
epoch_leave( epoch );
|
||||
}
|
||||
|
||||
@ -538,9 +538,9 @@ backend_reset( LloadBackend *b, int gentle )
|
||||
if ( b->b_retry_event &&
|
||||
event_pending( b->b_retry_event, EV_TIMEOUT, NULL ) ) {
|
||||
assert( b->b_failed );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
event_del( b->b_retry_event );
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_opening--;
|
||||
}
|
||||
if ( b->b_dns_req ) {
|
||||
@ -593,7 +593,7 @@ lload_backend_destroy( LloadBackend *b )
|
||||
"destroying backend uri='%s', numconns=%d, numbindconns=%d\n",
|
||||
b->b_uri.bv_val, b->b_numconns, b->b_numbindconns );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_numconns = b->b_numbindconns = 0;
|
||||
backend_reset( b, 0 );
|
||||
|
||||
@ -618,7 +618,7 @@ lload_backend_destroy( LloadBackend *b )
|
||||
assert( rc == LDAP_SUCCESS );
|
||||
}
|
||||
#endif /* BALANCER_MODULE */
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
ldap_pvt_thread_mutex_destroy( &b->b_mutex );
|
||||
|
||||
if ( b->b_retry_event ) {
|
||||
|
@ -331,16 +331,16 @@ request_bind( LloadConnection *client, LloadOperation *op )
|
||||
CONNECTION_UNLOCK(client);
|
||||
|
||||
if ( pin ) {
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
upstream = op->o_upstream;
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
|
||||
if ( upstream ) {
|
||||
ldap_pvt_thread_mutex_lock( &upstream->c_io_mutex );
|
||||
checked_lock( &upstream->c_io_mutex );
|
||||
CONNECTION_LOCK(upstream);
|
||||
if ( !IS_ALIVE( upstream, c_live ) ) {
|
||||
CONNECTION_UNLOCK(upstream);
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
upstream = NULL;
|
||||
}
|
||||
}
|
||||
@ -381,17 +381,17 @@ request_bind( LloadConnection *client, LloadOperation *op )
|
||||
|
||||
ber = upstream->c_pendingber;
|
||||
if ( ber == NULL && (ber = ber_alloc()) == NULL ) {
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
if ( !pin ) {
|
||||
LloadBackend *b = upstream->c_private;
|
||||
|
||||
upstream->c_n_ops_executing--;
|
||||
CONNECTION_UNLOCK(upstream);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_n_ops_executing--;
|
||||
operation_update_backend_counters( op, b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
} else {
|
||||
CONNECTION_UNLOCK(upstream);
|
||||
}
|
||||
@ -416,13 +416,13 @@ request_bind( LloadConnection *client, LloadOperation *op )
|
||||
pin = op->o_pin_id = 0;
|
||||
}
|
||||
} else if ( tag == LDAP_AUTH_SASL && !op->o_pin_id ) {
|
||||
ldap_pvt_thread_mutex_lock( &lload_pin_mutex );
|
||||
checked_lock( &lload_pin_mutex );
|
||||
pin = op->o_pin_id = lload_next_pin++;
|
||||
Debug( LDAP_DEBUG_CONNS, "request_bind: "
|
||||
"client connid=%lu allocated pin=%lu linking it to upstream "
|
||||
"connid=%lu\n",
|
||||
op->o_client_connid, pin, upstream->c_connid );
|
||||
ldap_pvt_thread_mutex_unlock( &lload_pin_mutex );
|
||||
checked_unlock( &lload_pin_mutex );
|
||||
}
|
||||
|
||||
op->o_upstream = upstream;
|
||||
@ -436,19 +436,19 @@ request_bind( LloadConnection *client, LloadOperation *op )
|
||||
LloadBackend *b = upstream->c_private;
|
||||
|
||||
upstream->c_n_ops_executing--;
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
CONNECTION_UNLOCK(upstream);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_n_ops_executing--;
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
assert( !IS_ALIVE( client, c_live ) );
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
if ( op->o_upstream ) {
|
||||
op->o_upstream = NULL;
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
rc = -1;
|
||||
goto done;
|
||||
}
|
||||
@ -481,7 +481,7 @@ request_bind( LloadConnection *client, LloadOperation *op )
|
||||
{
|
||||
rc = client_bind( op, upstream, &binddn, tag, &auth );
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
|
||||
done:
|
||||
|
||||
@ -534,10 +534,10 @@ finish_sasl_bind(
|
||||
|
||||
CONNECTION_UNLOCK(upstream);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &upstream->c_io_mutex );
|
||||
checked_lock( &upstream->c_io_mutex );
|
||||
output = upstream->c_pendingber;
|
||||
if ( output == NULL && (output = ber_alloc()) == NULL ) {
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
CONNECTION_LOCK_DESTROY(upstream);
|
||||
return -1;
|
||||
}
|
||||
@ -551,7 +551,7 @@ finish_sasl_bind(
|
||||
|
||||
/* Make sure noone flushes the buffer before we re-insert the operation */
|
||||
CONNECTION_LOCK(upstream);
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
|
||||
op->o_upstream_msgid = msgid;
|
||||
|
||||
@ -612,9 +612,9 @@ handle_bind_response(
|
||||
"connid=%lu, result=%d\n",
|
||||
op->o_client_msgid, op->o_client_connid, result );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
upstream = op->o_upstream;
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
if ( !upstream ) {
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
@ -763,9 +763,9 @@ handle_whoami_response(
|
||||
return -1;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
upstream = op->o_upstream;
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
if ( !upstream ) {
|
||||
return LDAP_SUCCESS;
|
||||
}
|
||||
@ -868,9 +868,9 @@ handle_vc_bind_response(
|
||||
if ( result == LDAP_PROTOCOL_ERROR ) {
|
||||
LloadConnection *upstream;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
upstream = op->o_upstream;
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
if ( upstream ) {
|
||||
LloadBackend *b;
|
||||
|
||||
@ -955,11 +955,11 @@ handle_vc_bind_response(
|
||||
}
|
||||
CONNECTION_UNLOCK(client);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &client->c_io_mutex );
|
||||
checked_lock( &client->c_io_mutex );
|
||||
output = client->c_pendingber;
|
||||
if ( output == NULL && (output = ber_alloc()) == NULL ) {
|
||||
rc = -1;
|
||||
ldap_pvt_thread_mutex_unlock( &client->c_io_mutex );
|
||||
checked_unlock( &client->c_io_mutex );
|
||||
goto done;
|
||||
}
|
||||
client->c_pendingber = output;
|
||||
@ -970,7 +970,7 @@ handle_vc_bind_response(
|
||||
LDAP_TAG_SASL_RES_CREDS, BER_BV_OPTIONAL( &creds ),
|
||||
LDAP_TAG_CONTROLS, BER_BV_OPTIONAL( &controls ) );
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &client->c_io_mutex );
|
||||
checked_unlock( &client->c_io_mutex );
|
||||
if ( rc >= 0 ) {
|
||||
connection_write_cb( -1, 0, client );
|
||||
rc = 0;
|
||||
|
@ -112,19 +112,19 @@ request_process( LloadConnection *client, LloadOperation *op )
|
||||
LloadBackend *b = upstream->c_private;
|
||||
|
||||
upstream->c_n_ops_executing--;
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
CONNECTION_UNLOCK(upstream);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_n_ops_executing--;
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
assert( !IS_ALIVE( client, c_live ) );
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
if ( op->o_upstream ) {
|
||||
op->o_upstream = NULL;
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -134,12 +134,12 @@ request_process( LloadConnection *client, LloadOperation *op )
|
||||
|
||||
upstream->c_n_ops_executing--;
|
||||
CONNECTION_UNLOCK(upstream);
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_n_ops_executing--;
|
||||
operation_update_backend_counters( op, b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
Debug( LDAP_DEBUG_ANY, "request_process: "
|
||||
"ber_alloc failed\n" );
|
||||
@ -187,7 +187,7 @@ request_process( LloadConnection *client, LloadOperation *op )
|
||||
op->o_tag, &op->o_request,
|
||||
LDAP_TAG_CONTROLS, BER_BV_OPTIONAL( &op->o_ctrls ) );
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
|
||||
connection_write_cb( -1, 0, upstream );
|
||||
return rc;
|
||||
@ -303,9 +303,9 @@ client_tls_handshake_cb( evutil_socket_t s, short what, void *arg )
|
||||
* Also before we try to read anything from the connection, it isn't
|
||||
* permitted to Abandon a StartTLS exop per RFC4511 anyway.
|
||||
*/
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
if ( c->c_pendingber ) {
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
connection_write_cb( s, what, arg );
|
||||
|
||||
if ( !IS_ALIVE( c, c_live ) ) {
|
||||
@ -314,15 +314,15 @@ client_tls_handshake_cb( evutil_socket_t s, short what, void *arg )
|
||||
|
||||
/* Do we still have data pending? If so, connection_write_cb would
|
||||
* already have arranged the write callback to trigger again */
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
if ( c->c_pendingber ) {
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rc = ldap_pvt_tls_accept( c->c_sb, LLOAD_TLS_CTX );
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
if ( rc < 0 ) {
|
||||
goto fail;
|
||||
}
|
||||
@ -452,9 +452,9 @@ client_init(
|
||||
/* We only register the write event when we have data pending */
|
||||
event_add( c->c_read_event, c->c_read_timeout );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
checked_lock( &clients_mutex );
|
||||
LDAP_CIRCLEQ_INSERT_TAIL( &clients, c, c_next );
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
checked_unlock( &clients_mutex );
|
||||
CONNECTION_UNLOCK(c);
|
||||
|
||||
return c;
|
||||
@ -536,9 +536,9 @@ client_unlink( LloadConnection *c )
|
||||
}
|
||||
|
||||
if ( state != LLOAD_C_DYING ) {
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
checked_lock( &clients_mutex );
|
||||
LDAP_CIRCLEQ_REMOVE( &clients, c, c_next );
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
checked_unlock( &clients_mutex );
|
||||
}
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
@ -575,8 +575,8 @@ client_destroy( LloadConnection *c )
|
||||
void
|
||||
clients_destroy( int gentle )
|
||||
{
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
checked_lock( &clients_mutex );
|
||||
connections_walk(
|
||||
&clients_mutex, &clients, lload_connection_close, &gentle );
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
checked_unlock( &clients_mutex );
|
||||
}
|
||||
|
@ -101,9 +101,9 @@ handle_pdus( void *ctx, void *arg )
|
||||
}
|
||||
c->c_currentber = ber;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
tag = ber_get_next( c->c_sb, &len, ber );
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
if ( tag != LDAP_TAG_MESSAGE ) {
|
||||
int err = sock_errno();
|
||||
|
||||
@ -198,9 +198,9 @@ connection_read_cb( evutil_socket_t s, short what, void *arg )
|
||||
}
|
||||
c->c_currentber = ber;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
tag = ber_get_next( c->c_sb, &len, ber );
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
|
||||
if ( tag != LDAP_TAG_MESSAGE ) {
|
||||
int err = sock_errno();
|
||||
@ -295,7 +295,7 @@ connection_write_cb( evutil_socket_t s, short what, void *arg )
|
||||
|
||||
epoch = epoch_join();
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
Debug( LDAP_DEBUG_CONNS, "connection_write_cb: "
|
||||
"have something to write to connection connid=%lu\n",
|
||||
c->c_connid );
|
||||
@ -306,7 +306,7 @@ connection_write_cb( evutil_socket_t s, short what, void *arg )
|
||||
|
||||
if ( err != EWOULDBLOCK && err != EAGAIN ) {
|
||||
char ebuf[128];
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
Debug( LDAP_DEBUG_ANY, "connection_write_cb: "
|
||||
"ber_flush on fd=%d failed errno=%d (%s)\n",
|
||||
c->c_fd, err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
@ -317,7 +317,7 @@ connection_write_cb( evutil_socket_t s, short what, void *arg )
|
||||
} else {
|
||||
c->c_pendingber = NULL;
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
|
||||
done:
|
||||
RELEASE_REF( c, c_refcnt, c->c_destroy );
|
||||
@ -418,12 +418,12 @@ connections_walk_last(
|
||||
do {
|
||||
int rc;
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( cq_mutex );
|
||||
checked_unlock( cq_mutex );
|
||||
|
||||
rc = cb( c, arg );
|
||||
RELEASE_REF( c, c_refcnt, c->c_destroy );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( cq_mutex );
|
||||
checked_lock( cq_mutex );
|
||||
if ( rc || LDAP_CIRCLEQ_EMPTY( cq ) ) {
|
||||
break;
|
||||
}
|
||||
|
@ -1319,10 +1319,10 @@ lloadd_daemon( struct event_base *daemon_base )
|
||||
return -1;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_retry_event = event;
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1354,10 +1354,10 @@ lloadd_daemon( struct event_base *daemon_base )
|
||||
|
||||
/* Mark upstream connections closing and prevent from opening new ones */
|
||||
LDAP_CIRCLEQ_FOREACH ( b, &backend, b_next ) {
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_numconns = b->b_numbindconns = 0;
|
||||
backend_reset( b, 1 );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
}
|
||||
|
||||
/* Do the same for clients */
|
||||
@ -1463,9 +1463,9 @@ lload_handle_backend_invalidation( LloadChange *change )
|
||||
if ( !current_backend ) {
|
||||
current_backend = b;
|
||||
}
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
return;
|
||||
} else if ( change->type == LLOAD_CHANGE_DEL ) {
|
||||
ldap_pvt_thread_pool_walk(
|
||||
@ -1486,10 +1486,10 @@ lload_handle_backend_invalidation( LloadChange *change )
|
||||
&connection_pool, handle_pdus, backend_conn_cb, b );
|
||||
ldap_pvt_thread_pool_walk(
|
||||
&connection_pool, upstream_bind, backend_conn_cb, b );
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
backend_reset( b, 0 );
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1602,9 +1602,9 @@ lload_handle_backend_invalidation( LloadChange *change )
|
||||
assert( need_close == 0 );
|
||||
|
||||
if ( need_open ) {
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1700,10 +1700,10 @@ lload_handle_global_invalidation( LloadChange *change )
|
||||
&connection_pool, upstream_bind, backend_conn_cb, NULL );
|
||||
|
||||
LDAP_CIRCLEQ_FOREACH ( b, &backend, b_next ) {
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
backend_reset( b, 0 );
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
}
|
||||
|
||||
/* Reconsider the PRIVILEGED flag on all clients */
|
||||
@ -1753,12 +1753,12 @@ lload_pause_event_cb( evutil_socket_t s, short what, void *arg )
|
||||
*
|
||||
* Do this in lockstep with the pausing thread.
|
||||
*/
|
||||
ldap_pvt_thread_mutex_lock( &lload_wait_mutex );
|
||||
checked_lock( &lload_wait_mutex );
|
||||
ldap_pvt_thread_cond_signal( &lload_wait_cond );
|
||||
|
||||
/* Now wait until we unpause, then we can resume operation */
|
||||
ldap_pvt_thread_cond_wait( &lload_pause_cond, &lload_wait_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &lload_wait_mutex );
|
||||
checked_unlock( &lload_wait_mutex );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1770,10 +1770,10 @@ lload_pause_base( struct event_base *base )
|
||||
{
|
||||
int rc;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &lload_wait_mutex );
|
||||
checked_lock( &lload_wait_mutex );
|
||||
event_base_once( base, -1, EV_TIMEOUT, lload_pause_event_cb, base, NULL );
|
||||
rc = ldap_pvt_thread_cond_wait( &lload_wait_cond, &lload_wait_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &lload_wait_mutex );
|
||||
checked_unlock( &lload_wait_mutex );
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -77,10 +77,10 @@ handle_starttls( LloadConnection *c, LloadOperation *op )
|
||||
* This means we can safely reconfigure both I/O events now.
|
||||
*/
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
output = c->c_pendingber;
|
||||
if ( output == NULL && (output = ber_alloc()) == NULL ) {
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
operation_unlink( op );
|
||||
CONNECTION_LOCK_DESTROY(c);
|
||||
return -1;
|
||||
@ -89,7 +89,7 @@ handle_starttls( LloadConnection *c, LloadOperation *op )
|
||||
ber_printf( output, "t{tit{ess}}", LDAP_TAG_MESSAGE,
|
||||
LDAP_TAG_MSGID, op->o_client_msgid,
|
||||
LDAP_RES_EXTENDED, LDAP_SUCCESS, "", "" );
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
c->c_read_timeout = lload_timeout_net;
|
||||
|
@ -86,6 +86,11 @@ LDAP_BEGIN_DECL
|
||||
|
||||
#include <epoch.h>
|
||||
|
||||
#define checked_lock( mutex ) \
|
||||
if ( ldap_pvt_thread_mutex_lock( mutex ) != 0 ) assert(0)
|
||||
#define checked_unlock( mutex ) \
|
||||
if ( ldap_pvt_thread_mutex_unlock( mutex ) != 0 ) assert(0)
|
||||
|
||||
typedef struct LloadBackend LloadBackend;
|
||||
typedef struct LloadPendingConnection LloadPendingConnection;
|
||||
typedef struct LloadConnection LloadConnection;
|
||||
@ -297,8 +302,14 @@ struct LloadConnection {
|
||||
CONNECTION_DESTROY_CB c_unlink;
|
||||
CONNECTION_DESTROY_CB c_destroy;
|
||||
CONNECTION_PDU_CB c_pdu_cb;
|
||||
#define CONNECTION_LOCK(c) ldap_pvt_thread_mutex_lock( &(c)->c_mutex )
|
||||
#define CONNECTION_UNLOCK(c) ldap_pvt_thread_mutex_unlock( &(c)->c_mutex )
|
||||
#define CONNECTION_LOCK(c) \
|
||||
do { \
|
||||
checked_lock( &(c)->c_mutex ); \
|
||||
} while (0)
|
||||
#define CONNECTION_UNLOCK(c) \
|
||||
do { \
|
||||
checked_unlock( &(c)->c_mutex ); \
|
||||
} while (0)
|
||||
#define CONNECTION_UNLINK_(c) \
|
||||
do { \
|
||||
if ( __atomic_exchange_n( &(c)->c_live, 0, __ATOMIC_ACQ_REL ) ) { \
|
||||
|
@ -110,10 +110,10 @@ lload_back_close( BackendInfo *bi )
|
||||
return 0;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &lload_wait_mutex );
|
||||
checked_lock( &lload_wait_mutex );
|
||||
event_base_loopexit( daemon_base, NULL );
|
||||
ldap_pvt_thread_cond_wait( &lload_wait_cond, &lload_wait_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &lload_wait_mutex );
|
||||
checked_unlock( &lload_wait_mutex );
|
||||
ldap_pvt_thread_join( lloadd_main_thread, (void *)NULL );
|
||||
|
||||
return 0;
|
||||
|
@ -548,10 +548,10 @@ lload_monitor_in_conn_create(
|
||||
mp_parent = e_parent->e_private;
|
||||
arg.ms = (monitor_subsys_t *)mp_parent->mp_info;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
checked_lock( &clients_mutex );
|
||||
connections_walk(
|
||||
&clients_mutex, &clients, lload_monitor_in_conn_entry, &arg );
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
checked_unlock( &clients_mutex );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -655,13 +655,13 @@ lload_monitor_up_conn_create(
|
||||
|
||||
arg.ms = ms;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
connections_walk_last( &b->b_mutex, &b->b_conns, b->b_last_conn,
|
||||
lload_monitor_up_conn_entry, &arg );
|
||||
|
||||
connections_walk_last( &b->b_mutex, &b->b_bindconns, b->b_last_bindconn,
|
||||
lload_monitor_up_conn_entry, &arg );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -722,7 +722,7 @@ lload_monitor_server_update(
|
||||
failed = 0;
|
||||
int i;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
active = b->b_active + b->b_bindavail;
|
||||
|
||||
LDAP_CIRCLEQ_FOREACH ( c, &b->b_preparing, c_next ) {
|
||||
@ -743,7 +743,7 @@ lload_monitor_server_update(
|
||||
assert( a != NULL );
|
||||
UI2BV( &a->a_vals[0], (long long unsigned int)b->b_n_ops_executing );
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
/* Right now, there is no way to retrieve the entry from monitor's
|
||||
* cache to replace URI at the moment it is modified */
|
||||
@ -935,13 +935,13 @@ lload_monitor_update_global_stats( void *ctx, void *arg )
|
||||
"updating stats\n" );
|
||||
|
||||
/* count incoming connections */
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
checked_lock( &clients_mutex );
|
||||
connections_walk( &clients_mutex, &clients, lload_monitor_incoming_count,
|
||||
&tmp_stats );
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
checked_unlock( &clients_mutex );
|
||||
|
||||
LDAP_CIRCLEQ_FOREACH ( b, &backend, b_next ) {
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
tmp_stats.global_outgoing += b->b_active + b->b_bindavail;
|
||||
|
||||
/* merge completed and failed stats */
|
||||
@ -951,7 +951,7 @@ lload_monitor_update_global_stats( void *ctx, void *arg )
|
||||
tmp_stats.counters[i].lc_ops_failed +=
|
||||
b->b_counters[i].lc_ops_failed;
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
}
|
||||
|
||||
/* update lload_stats */
|
||||
@ -965,9 +965,9 @@ lload_monitor_update_global_stats( void *ctx, void *arg )
|
||||
}
|
||||
|
||||
/* reschedule */
|
||||
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
|
||||
checked_lock( &slapd_rq.rq_mutex );
|
||||
ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
|
||||
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
|
||||
checked_unlock( &slapd_rq.rq_mutex );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1141,10 +1141,10 @@ lload_monitor_open( void )
|
||||
}
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
|
||||
checked_lock( &slapd_rq.rq_mutex );
|
||||
ldap_pvt_runqueue_insert( &slapd_rq, 1, lload_monitor_update_global_stats,
|
||||
NULL, "lload_monitor_update_global_stats", "lloadd" );
|
||||
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
|
||||
checked_unlock( &slapd_rq.rq_mutex );
|
||||
|
||||
return (lload_monitor_initialized_failure = LDAP_SUCCESS);
|
||||
}
|
||||
|
@ -231,13 +231,13 @@ operation_unlink( LloadOperation *op )
|
||||
"client msgid=%d\n",
|
||||
op->o_client_connid, op->o_upstream_connid, op->o_client_msgid );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
client = op->o_client;
|
||||
upstream = op->o_upstream;
|
||||
|
||||
op->o_client = NULL;
|
||||
op->o_upstream = NULL;
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
|
||||
assert( client || upstream );
|
||||
|
||||
@ -332,10 +332,10 @@ operation_unlink_upstream( LloadOperation *op, LloadConnection *upstream )
|
||||
}
|
||||
|
||||
if ( b ) {
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_n_ops_executing--;
|
||||
operation_update_backend_counters( op, b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -351,7 +351,7 @@ operation_send_abandon( LloadOperation *op, LloadConnection *upstream )
|
||||
return rc;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &upstream->c_io_mutex );
|
||||
checked_lock( &upstream->c_io_mutex );
|
||||
ber = upstream->c_pendingber;
|
||||
if ( ber == NULL && (ber = ber_alloc()) == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "operation_send_abandon: "
|
||||
@ -383,7 +383,7 @@ operation_send_abandon( LloadOperation *op, LloadConnection *upstream )
|
||||
rc = LDAP_SUCCESS;
|
||||
|
||||
done:
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
checked_unlock( &upstream->c_io_mutex );
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -401,9 +401,9 @@ operation_abandon( LloadOperation *op )
|
||||
{
|
||||
LloadConnection *c;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
c = op->o_upstream;
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
if ( !c || !IS_ALIVE( c, c_live ) ) {
|
||||
goto done;
|
||||
}
|
||||
@ -444,9 +444,9 @@ operation_send_reject(
|
||||
"rejecting %s from client connid=%lu with message: \"%s\"\n",
|
||||
lload_msgtype2str( op->o_tag ), op->o_client_connid, msg );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
c = op->o_client;
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
if ( !c || !IS_ALIVE( c, c_live ) ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "operation_send_reject: "
|
||||
"not sending msgid=%d, client connid=%lu is dead\n",
|
||||
@ -472,10 +472,10 @@ operation_send_reject(
|
||||
goto done;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
ber = c->c_pendingber;
|
||||
if ( ber == NULL && (ber = ber_alloc()) == NULL ) {
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
Debug( LDAP_DEBUG_ANY, "operation_send_reject: "
|
||||
"ber_alloc failed, closing connid=%lu\n",
|
||||
c->c_connid );
|
||||
@ -488,7 +488,7 @@ operation_send_reject(
|
||||
LDAP_TAG_MSGID, op->o_client_msgid,
|
||||
slap_req2res( op->o_tag ), result, "", msg );
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
|
||||
connection_write_cb( -1, 0, c );
|
||||
|
||||
@ -570,9 +570,9 @@ connection_timeout( LloadConnection *upstream, void *arg )
|
||||
nops, upstream->c_connid );
|
||||
CONNECTION_UNLOCK(upstream);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
b->b_n_ops_executing -= nops;
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
for ( node = tavl_end( ops, TAVL_DIR_LEFT ); node;
|
||||
node = tavl_next( node, TAVL_DIR_RIGHT ) ) {
|
||||
@ -621,9 +621,9 @@ operations_timeout( evutil_socket_t s, short what, void *arg )
|
||||
LDAP_CIRCLEQ_FOREACH ( b, &backend, b_next ) {
|
||||
epoch_t epoch;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
if ( b->b_n_ops_executing == 0 ) {
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -642,7 +642,7 @@ operations_timeout( evutil_socket_t s, short what, void *arg )
|
||||
connection_timeout, &threshold );
|
||||
|
||||
epoch_leave( epoch );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
}
|
||||
done:
|
||||
Debug( LDAP_DEBUG_TRACE, "operations_timeout: "
|
||||
|
@ -70,11 +70,11 @@ forward_response( LloadConnection *client, LloadOperation *op, BerElement *ber )
|
||||
"%s to client connid=%lu request msgid=%d\n",
|
||||
lload_msgtype2str( response_tag ), op->o_client_connid, msgid );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &client->c_io_mutex );
|
||||
checked_lock( &client->c_io_mutex );
|
||||
output = client->c_pendingber;
|
||||
if ( output == NULL && (output = ber_alloc()) == NULL ) {
|
||||
ber_free( ber, 1 );
|
||||
ldap_pvt_thread_mutex_unlock( &client->c_io_mutex );
|
||||
checked_unlock( &client->c_io_mutex );
|
||||
return -1;
|
||||
}
|
||||
client->c_pendingber = output;
|
||||
@ -84,7 +84,7 @@ forward_response( LloadConnection *client, LloadOperation *op, BerElement *ber )
|
||||
response_tag, &response,
|
||||
LDAP_TAG_CONTROLS, BER_BV_OPTIONAL( &controls ) );
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &client->c_io_mutex );
|
||||
checked_unlock( &client->c_io_mutex );
|
||||
|
||||
ber_free( ber, 1 );
|
||||
connection_write_cb( -1, 0, client );
|
||||
@ -244,9 +244,9 @@ handle_one_response( LloadConnection *c )
|
||||
if ( handler ) {
|
||||
LloadConnection *client;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
checked_lock( &op->o_link_mutex );
|
||||
client = op->o_client;
|
||||
ldap_pvt_thread_mutex_unlock( &op->o_link_mutex );
|
||||
checked_unlock( &op->o_link_mutex );
|
||||
if ( client && IS_ALIVE( client, c_live ) ) {
|
||||
rc = handler( client, op, ber );
|
||||
} else {
|
||||
@ -454,10 +454,10 @@ upstream_bind_cb( LloadConnection *c )
|
||||
if ( result == LDAP_SASL_BIND_IN_PROGRESS ) {
|
||||
BerElement *outber;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
outber = c->c_pendingber;
|
||||
if ( outber == NULL && (outber = ber_alloc()) == NULL ) {
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
goto fail;
|
||||
}
|
||||
c->c_pendingber = outber;
|
||||
@ -467,7 +467,7 @@ upstream_bind_cb( LloadConnection *c )
|
||||
msgid, LDAP_REQ_BIND, LDAP_VERSION3,
|
||||
&bindconf.sb_binddn, LDAP_AUTH_SASL,
|
||||
&c->c_sasl_bind_mech, BER_BV_OPTIONAL( &ccred ) );
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
|
||||
connection_write_cb( -1, 0, c );
|
||||
|
||||
@ -490,7 +490,7 @@ upstream_bind_cb( LloadConnection *c )
|
||||
"connid=%lu finished binding, now active\n",
|
||||
c->c_connid );
|
||||
CONNECTION_UNLOCK(c);
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
LDAP_CIRCLEQ_REMOVE( &b->b_preparing, c, c_next );
|
||||
b->b_active++;
|
||||
b->b_opening--;
|
||||
@ -503,7 +503,7 @@ upstream_bind_cb( LloadConnection *c )
|
||||
}
|
||||
b->b_last_conn = c;
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
break;
|
||||
default:
|
||||
Debug( LDAP_DEBUG_ANY, "upstream_bind_cb: "
|
||||
@ -542,7 +542,7 @@ upstream_bind( void *ctx, void *arg )
|
||||
c->c_pdu_cb = upstream_bind_cb;
|
||||
CONNECTION_UNLOCK(c);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
ber = c->c_pendingber;
|
||||
if ( ber == NULL && (ber = ber_alloc()) == NULL ) {
|
||||
goto fail;
|
||||
@ -577,7 +577,7 @@ upstream_bind( void *ctx, void *arg )
|
||||
}
|
||||
#endif /* HAVE_CYRUS_SASL */
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
|
||||
connection_write_cb( -1, 0, c );
|
||||
|
||||
@ -590,7 +590,7 @@ upstream_bind( void *ctx, void *arg )
|
||||
return NULL;
|
||||
|
||||
fail:
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
CONNECTION_LOCK_DESTROY(c);
|
||||
RELEASE_REF( c, c_refcnt, c->c_destroy );
|
||||
return NULL;
|
||||
@ -724,11 +724,11 @@ upstream_tls_handshake_cb( evutil_socket_t s, short what, void *arg )
|
||||
c->c_is_tls = LLOAD_TLS_ESTABLISHED;
|
||||
|
||||
CONNECTION_UNLOCK(c);
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
CONNECTION_LOCK(c);
|
||||
|
||||
rc = upstream_finish( c );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
if ( rc ) {
|
||||
goto fail;
|
||||
@ -816,11 +816,11 @@ upstream_starttls( LloadConnection *c )
|
||||
c->c_is_tls = LLOAD_CLEARTEXT;
|
||||
|
||||
CONNECTION_UNLOCK(c);
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
CONNECTION_LOCK(c);
|
||||
|
||||
rc = upstream_finish( c );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
if ( rc ) {
|
||||
goto fail;
|
||||
@ -923,16 +923,16 @@ upstream_init( ber_socket_t s, LloadBackend *b )
|
||||
c->c_is_tls == LLOAD_STARTTLS_OPTIONAL ) {
|
||||
BerElement *output;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
checked_lock( &c->c_io_mutex );
|
||||
if ( (output = c->c_pendingber = ber_alloc()) == NULL ) {
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
goto fail;
|
||||
}
|
||||
ber_printf( output, "t{tit{ts}}", LDAP_TAG_MESSAGE,
|
||||
LDAP_TAG_MSGID, c->c_next_msgid++,
|
||||
LDAP_REQ_EXTENDED,
|
||||
LDAP_TAG_EXOP_REQ_OID, LDAP_EXOP_START_TLS );
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
checked_unlock( &c->c_io_mutex );
|
||||
|
||||
c->c_pdu_cb = upstream_starttls;
|
||||
CONNECTION_UNLOCK(c);
|
||||
@ -1007,7 +1007,7 @@ upstream_unlink( LloadConnection *c )
|
||||
event_del( write_event );
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
checked_lock( &b->b_mutex );
|
||||
if ( c->c_type == LLOAD_C_PREPARING ) {
|
||||
LDAP_CIRCLEQ_REMOVE( &b->b_preparing, c, c_next );
|
||||
b->b_opening--;
|
||||
@ -1039,7 +1039,7 @@ upstream_unlink( LloadConnection *c )
|
||||
}
|
||||
b->b_n_ops_executing -= executing;
|
||||
backend_retry( b );
|
||||
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
|
||||
checked_unlock( &b->b_mutex );
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user