]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Free all pending operations on shutdown
authorOndřej Kuzník <ondra@mistotebe.net>
Thu, 25 May 2017 14:04:42 +0000 (15:04 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:55:46 +0000 (17:55 +0000)
servers/lloadd/backend.c

index f9226accea3215faca3d88a71c9a30a7cf317459..51b5aeb089fccc02a9e83106b459d2b996f38f90 100644 (file)
@@ -314,12 +314,45 @@ backends_destroy( void )
 
         while ( !LDAP_CIRCLEQ_EMPTY( &b->b_bindconns ) ) {
             Connection *c = LDAP_CIRCLEQ_FIRST( &b->b_bindconns );
+            TAvlnode *root;
+            long freed;
+
             CONNECTION_LOCK(c);
+            Debug( LDAP_DEBUG_CONNS, "backends_destroy: "
+                    "destroying bind connection connid=%lu, pending ops=%ld\n",
+                    c->c_connid, c->c_n_ops_executing );
+
+            root = c->c_ops;
+            c->c_ops = NULL;
+            CONNECTION_UNLOCK_INCREF(c);
+
+            freed = tavl_free( root, (AVL_FREE)operation_lost_upstream );
+
+            CONNECTION_LOCK_DECREF(c);
+            assert( freed == c->c_n_ops_executing );
+            assert( c->c_live );
             UPSTREAM_DESTROY(c);
         }
         while ( !LDAP_CIRCLEQ_EMPTY( &b->b_conns ) ) {
             Connection *c = LDAP_CIRCLEQ_FIRST( &b->b_conns );
+            TAvlnode *root;
+            long freed;
+
             CONNECTION_LOCK(c);
+            Debug( LDAP_DEBUG_CONNS, "backends_destroy: "
+                    "destroying regular connection connid=%lu, pending "
+                    "ops=%ld\n",
+                    c->c_connid, c->c_n_ops_executing );
+
+            root = c->c_ops;
+            c->c_ops = NULL;
+            CONNECTION_UNLOCK_INCREF(c);
+
+            freed = tavl_free( root, (AVL_FREE)operation_lost_upstream );
+
+            CONNECTION_LOCK_DECREF(c);
+            assert( freed == c->c_n_ops_executing );
+            assert( c->c_live );
             UPSTREAM_DESTROY(c);
         }