Commit 873d6fa3 authored by Ondřej Kuzník's avatar Ondřej Kuzník Committed by Ondřej Kuzník
Browse files

Handle backend unsolicited response properly

parent 9d3b998a
......@@ -271,25 +271,13 @@ done:
static int
handle_unsolicited( Connection *c, BerElement *ber )
{
TAvlnode *root;
long freed, executing;
c->c_state = SLAP_C_CLOSING;
Debug( LDAP_DEBUG_CONNS, "handle_unsolicited: "
"teardown for upstream connection %lu\n",
c->c_connid );
root = c->c_ops;
c->c_ops = NULL;
executing = c->c_n_ops_executing;
CONNECTION_UNLOCK_INCREF(c);
freed = tavl_free( root, (AVL_FREE)operation_lost_upstream );
assert( freed == executing );
Debug( LDAP_DEBUG_TRACE, "handle_unsolicited: "
"dropped %ld operations\n",
freed );
UPSTREAM_LOCK_DESTROY(c);
UPSTREAM_DESTROY(c);
ber_free( ber, 1 );
return -1;
......@@ -902,7 +890,7 @@ upstream_destroy( Connection *c )
Backend *b = c->c_private;
struct event *read_event, *write_event;
TAvlnode *root;
long freed;
long freed, executing;
Debug( LDAP_DEBUG_CONNS, "upstream_destroy: "
"freeing connection %lu\n",
......@@ -912,12 +900,14 @@ upstream_destroy( Connection *c )
root = c->c_ops;
c->c_ops = NULL;
executing = c->c_n_ops_executing;
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 );
assert( freed == executing );
/*
* Avoid a deadlock:
......@@ -940,7 +930,7 @@ upstream_destroy( Connection *c )
LDAP_CIRCLEQ_REMOVE( &b->b_conns, c, c_next );
b->b_active--;
}
b->b_n_ops_executing -= c->c_n_ops_executing;
b->b_n_ops_executing -= executing;
ldap_pvt_thread_mutex_unlock( &b->b_mutex );
backend_retry( b );
......
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