]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Stop the read callback on a dead connection.
authorOndřej Kuzník <ondra@mistotebe.net>
Tue, 9 May 2017 15:24:14 +0000 (16:24 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:55:46 +0000 (17:55 +0000)
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.

servers/lloadd/client.c
servers/lloadd/upstream.c

index 51f7c78467220e662fcff13e8217a97f42ee8aa3..dd85b26a22fd42df3bb8ef30336e8833cc48235e 100644 (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;
         }
index 6a30e82c1eacdba30c6bbea58d967d14617fc941..54f157f60d2d185cdbd77eeff163a945013f4b28 100644 (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;
         }