]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9468 do not arm expire timer for connections that are already tainted
authorTero Saarni <tero.saarni@est.tech>
Thu, 13 May 2021 18:13:08 +0000 (21:13 +0300)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 8 Jun 2021 15:41:40 +0000 (15:41 +0000)
servers/slapd/back-ldap/bind.c

index b0dd0a17a3886a9b7f5b0e6e9c311c9fee4be7e0..c86a253cf2ee0e4eac84020f3a562788ac9660af 100644 (file)
@@ -3113,6 +3113,38 @@ ldap_back_conn_prune( ldapinfo_t *li )
 
                while ( lc ) {
                        ldapconn_t *next = LDAP_TAILQ_NEXT( lc, lc_q );
+
+                       if ( !LDAP_BACK_CONN_TAINTED( lc ) ) {
+                               time_t conn_expires = ldap_back_conn_expire_time( li, lc );
+
+                               if ( now >= conn_expires ) {
+                                       if ( lc->lc_refcnt == 0 ) {
+                                               Debug( LDAP_DEBUG_TRACE,
+                                                       "ldap_back_conn_prune: closing expired connection lc=%p\n",
+                                                       lc );
+                                               ldap_back_freeconn( li, lc, 0 );
+                                       } else {
+                                               Debug( LDAP_DEBUG_TRACE,
+                                                       "ldap_back_conn_prune: tainting expired connection lc=%p\n",
+                                                       lc );
+                                               LDAP_BACK_CONN_TAINTED_SET( lc );
+                                       }
+                               } else if ( next_timeout == -1 || conn_expires < next_timeout ) {
+                                       /* next_timeout was not yet initialized or current connection expires sooner */
+                                       next_timeout = conn_expires;
+                               }
+                       }
+
+                       lc = next;
+               }
+       }
+
+       edge = ldap_tavl_end( li->li_conninfo.lai_tree, TAVL_DIR_LEFT );
+       while ( edge ) {
+               TAvlnode *next = ldap_tavl_next( edge, TAVL_DIR_RIGHT );
+               ldapconn_t *lc = (ldapconn_t *)edge->avl_data;
+
+               if ( !LDAP_BACK_CONN_TAINTED( lc ) ) {
                        time_t conn_expires = ldap_back_conn_expire_time( li, lc );
 
                        if ( now >= conn_expires ) {
@@ -3128,34 +3160,8 @@ ldap_back_conn_prune( ldapinfo_t *li )
                                        LDAP_BACK_CONN_TAINTED_SET( lc );
                                }
                        } else if ( next_timeout == -1 || conn_expires < next_timeout ) {
-                               /* next_timeout was not yet initialized or current connection expires sooner */
                                next_timeout = conn_expires;
                        }
-
-                       lc = next;
-               }
-       }
-
-       edge = ldap_tavl_end( li->li_conninfo.lai_tree, TAVL_DIR_LEFT );
-       while ( edge ) {
-               TAvlnode *next = ldap_tavl_next( edge, TAVL_DIR_RIGHT );
-               ldapconn_t *lc = (ldapconn_t *)edge->avl_data;
-               time_t conn_expires = ldap_back_conn_expire_time( li, lc );
-
-               if ( now >= conn_expires ) {
-                       if ( lc->lc_refcnt == 0 ) {
-                               Debug( LDAP_DEBUG_TRACE,
-                                       "ldap_back_conn_prune: closing expired connection lc=%p\n",
-                                       lc );
-                               ldap_back_freeconn( li, lc, 0 );
-                       } else {
-                               Debug( LDAP_DEBUG_TRACE,
-                                       "ldap_back_conn_prune: tainting expired connection lc=%p\n",
-                                       lc );
-                               LDAP_BACK_CONN_TAINTED_SET( lc );
-                       }
-               } else if ( next_timeout == -1 || conn_expires < next_timeout ) {
-                       next_timeout = conn_expires;
                }
 
                edge = next;