diff --git a/servers/lloadd/client.c b/servers/lloadd/client.c index 466d065d06..0057b86439 100644 --- a/servers/lloadd/client.c +++ b/servers/lloadd/client.c @@ -111,7 +111,10 @@ client_read_cb( evutil_socket_t s, short what, void *arg ) "suspended read event on connid=%lu\n", c->c_connid ); - CONNECTION_UNLOCK(c); + /* We have scheduled a call to handle_requests which takes care of + * handling further requests, just make sure the connection sticks around + * for that */ + CONNECTION_UNLOCK_INCREF(c); return; } @@ -121,7 +124,7 @@ handle_requests( void *ctx, void *arg ) Connection *c = arg; int requests_handled = 0; - CONNECTION_LOCK(c); + CONNECTION_LOCK_DECREF(c); for ( ; requests_handled < slap_conn_max_pdus_per_cycle; requests_handled++ ) { BerElement *ber; diff --git a/servers/lloadd/operation.c b/servers/lloadd/operation.c index 0d0b2898b5..8ff873a2ae 100644 --- a/servers/lloadd/operation.c +++ b/servers/lloadd/operation.c @@ -237,7 +237,7 @@ operation_destroy_from_client( Operation *op ) ldap_pvt_thread_mutex_unlock( &op->o_mutex ); assert( upstream != NULL ); - CONNECTION_UNLOCK(upstream); + UPSTREAM_UNLOCK_OR_DESTROY(upstream); CONNECTION_LOCK_DECREF(client); return; } @@ -381,7 +381,7 @@ operation_destroy_from_upstream( Operation *op ) ldap_pvt_thread_mutex_unlock( &op->o_mutex ); assert( client != NULL ); - CONNECTION_UNLOCK(client); + CLIENT_UNLOCK_OR_DESTROY(client); CONNECTION_LOCK_DECREF(upstream); return; } @@ -743,11 +743,13 @@ fail: if ( upstream ) { ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex ); CONNECTION_LOCK_DECREF(upstream); + upstream->c_n_ops_executing--; UPSTREAM_UNLOCK_OR_DESTROY(upstream); operation_send_reject( op, LDAP_OTHER, "internal error", 0 ); } CONNECTION_LOCK_DECREF(client); op->o_client_refcnt--; operation_destroy_from_client( op ); - return rc; + CLIENT_UNLOCK_OR_DESTROY(client); + return -1; } diff --git a/servers/lloadd/upstream.c b/servers/lloadd/upstream.c index f6fbc5fa63..8485afe658 100644 --- a/servers/lloadd/upstream.c +++ b/servers/lloadd/upstream.c @@ -922,9 +922,11 @@ upstream_destroy( Connection *c ) root = c->c_ops; c->c_ops = NULL; executing = c->c_n_ops_executing; + c->c_n_ops_executing = 0; read_event = c->c_read_event; write_event = c->c_write_event; + CONNECTION_UNLOCK_INCREF(c); freed = tavl_free( root, (AVL_FREE)operation_lost_upstream );