]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10266 Adopt broader RFC4511 NoD interpretation, receiving side
authorOndřej Kuzník <ondra@mistotebe.net>
Wed, 14 Aug 2024 09:55:29 +0000 (10:55 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 19 Feb 2025 19:59:42 +0000 (19:59 +0000)
servers/lloadd/upstream.c

index 13d05a6927c7388b382cd90cc8f442340d50fdad..7d558dc54abe3caab014cbf6e5c5cd55ae6fe94f 100644 (file)
@@ -138,6 +138,8 @@ forward_final_response(
 static int
 handle_unsolicited( LloadConnection *c, BerElement *ber )
 {
+    TAvlnode *node;
+
     CONNECTION_ASSERT_LOCKED(c);
 
     assert( c->c_state != LLOAD_C_INVALID );
@@ -151,10 +153,30 @@ handle_unsolicited( LloadConnection *c, BerElement *ber )
             "teardown for upstream connection connid=%lu\n",
             c->c_connid );
 
-    CONNECTION_DESTROY(c);
+    while ( c->c_ops ) {
+        TAvlnode *node = ldap_tavl_end( c->c_ops, TAVL_DIR_LEFT );
+        LloadOperation *op = node->avl_data;
+
+        /* Close operations that the upstream is not tracking, we don't get a
+         * response for those. */
+        if ( op->o_client_msgid || op->o_upstream_msgid ) {
+            assert( op->o_upstream_msgid != 0 );
+            break;
+        }
+
+        CONNECTION_UNLOCK(c);
+        OPERATION_UNLINK(op);
+        CONNECTION_LOCK(c);
+    };
 
 out:
     ber_free( ber, 1 );
+    if ( c->c_state == LLOAD_C_CLOSING && c->c_ops ) {
+        CONNECTION_UNLOCK(c);
+        return 0;
+    }
+
+    CONNECTION_DESTROY(c);
     return -1;
 }