Stop the read callback on a dead connection.

The connection might be ready to read (close) but if we can't destroy it
yet, we don't want the callback to trigger all the time or process new
data.
This commit is contained in:
Ondřej Kuzník 2017-05-09 16:24:14 +01:00 committed by Ondřej Kuzník
parent 6899d0123d
commit 8eb7f3fbca
2 changed files with 14 additions and 0 deletions

View file

@ -35,6 +35,11 @@ client_read_cb( evutil_socket_t s, short what, void *arg )
ber_len_t len;
CONNECTION_LOCK(c);
if ( !c->c_live ) {
event_del( c->c_read_event );
CONNECTION_UNLOCK(c);
return;
}
Debug( LDAP_DEBUG_CONNS, "client_read_cb: "
"connection %lu ready to read\n",
@ -61,6 +66,8 @@ client_read_cb( evutil_socket_t s, short what, void *arg )
c->c_currentber = NULL;
ber_free( ber, 1 );
event_del( c->c_read_event );
CLIENT_DESTROY(c);
return;
}

View file

@ -488,6 +488,11 @@ upstream_read_cb( evutil_socket_t s, short what, void *arg )
ber_len_t len;
CONNECTION_LOCK(c);
if ( !c->c_live ) {
event_del( c->c_read_event );
CONNECTION_UNLOCK(c);
return;
}
Debug( LDAP_DEBUG_CONNS, "upstream_read_cb: "
"connection %lu ready to read\n",
c->c_connid );
@ -513,6 +518,8 @@ upstream_read_cb( evutil_socket_t s, short what, void *arg )
c->c_currentber = NULL;
ber_free( ber, 1 );
event_del( c->c_read_event );
UPSTREAM_DESTROY(c);
return;
}