Commit f832024e authored by Ondřej Kuzník's avatar Ondřej Kuzník
Browse files

Straighten up client pending op tracking

parent dc1961cb
......@@ -244,6 +244,7 @@ request_bind( LloadConnection *client, LloadOperation *op )
}
tavl_delete( &client->c_ops, op, operation_client_cmp );
client->c_n_ops_executing--;
client_reset( client );
......@@ -326,6 +327,7 @@ request_bind( LloadConnection *client, LloadOperation *op )
rc = tavl_insert( &client->c_ops, op, operation_client_cmp, avl_dup_error );
assert( rc == LDAP_SUCCESS );
client->c_n_ops_executing++;
CONNECTION_UNLOCK(client);
if ( pin ) {
......@@ -663,6 +665,7 @@ handle_bind_response(
assert( !removed || op == removed );
if ( client->c_state == LLOAD_C_BINDING ) {
assert( removed );
switch ( result ) {
case LDAP_SASL_BIND_IN_PROGRESS:
op->o_saved_msgid = op->o_client_msgid;
......@@ -676,6 +679,7 @@ handle_bind_response(
client->c_state = LLOAD_C_READY;
client->c_type = LLOAD_C_OPEN;
client->c_pin_id = 0;
client->c_n_ops_executing--;
if ( !BER_BVISNULL( &client->c_auth ) ) {
if ( result != LDAP_SUCCESS ) {
ber_memfree( client->c_auth.bv_val );
......@@ -693,6 +697,9 @@ handle_bind_response(
}
}
} else {
if ( removed ) {
client->c_n_ops_executing--;
}
assert( client->c_state == LLOAD_C_DYING ||
client->c_state == LLOAD_C_CLOSING );
}
......@@ -783,6 +790,9 @@ handle_whoami_response(
removed = tavl_delete( &client->c_ops, op, operation_client_cmp );
assert( !removed || op == removed );
op->o_pin_id = 0;
if ( removed ) {
client->c_n_ops_executing--;
}
Debug( LDAP_DEBUG_TRACE, "handle_whoami_response: "
"connid=%ld new authid=%s\n",
......
......@@ -445,9 +445,12 @@ void
client_reset( LloadConnection *c )
{
TAvlnode *root;
long freed = 0, executing;
root = c->c_ops;
c->c_ops = NULL;
executing = c->c_n_ops_executing;
c->c_n_ops_executing = 0;
if ( !BER_BVISNULL( &c->c_auth ) ) {
ch_free( c->c_auth.bv_val );
......@@ -460,12 +463,12 @@ client_reset( LloadConnection *c )
CONNECTION_UNLOCK(c);
if ( root ) {
int freed;
freed = tavl_free( root, (AVL_FREE)operation_abandon );
Debug( LDAP_DEBUG_TRACE, "client_reset: "
"dropped %d operations\n",
"dropped %ld operations\n",
freed );
}
assert( freed == executing );
CONNECTION_LOCK(c);
}
......
......@@ -32,12 +32,15 @@ int
handle_starttls( LloadConnection *c, LloadOperation *op )
{
struct event_base *base = event_get_base( c->c_read_event );
LloadOperation *found;
BerElement *output;
char *msg = NULL;
int rc = LDAP_SUCCESS;
CONNECTION_LOCK(c);
tavl_delete( &c->c_ops, op, operation_client_cmp );
found = tavl_delete( &c->c_ops, op, operation_client_cmp );
assert( op == found );
c->c_n_ops_executing--;
if ( c->c_is_tls == LLOAD_TLS_ESTABLISHED ) {
rc = LDAP_OPERATIONS_ERROR;
......
Markdown is supported
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