]> git.sur5r.net Git - openldap/commitdiff
Free thread keys in reverse order of allocation
authorHoward Chu <hyc@openldap.org>
Thu, 25 Jan 2007 11:13:15 +0000 (11:13 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 25 Jan 2007 11:13:15 +0000 (11:13 +0000)
libraries/libldap_r/tpool.c

index d8a4f53cebf0bf9c4cd3b8311de4e6eb8622ef16..a6ba2062ba5d2228bd563aa077a067d69b49a3c7 100644 (file)
@@ -720,12 +720,7 @@ ldap_int_thread_pool_wrapper (
                }
        }
 
-       for ( i=0; i<MAXKEYS && uctx.ltu_key[i].ltk_key; i++ ) {
-               if (uctx.ltu_key[i].ltk_free)
-                       uctx.ltu_key[i].ltk_free(
-                               uctx.ltu_key[i].ltk_key,
-                               uctx.ltu_key[i].ltk_data );
-       }
+       ldap_pvt_thread_pool_context_reset(&uctx);
 
        thread_keys[keyslot].ctx = NULL;
        thread_keys[keyslot].id = tid_zero;
@@ -895,7 +890,9 @@ void ldap_pvt_thread_pool_context_reset( void *vctx )
        ldap_int_thread_userctx_t *ctx = vctx;
        int i;
 
-       for ( i=0; i<MAXKEYS && ctx->ltu_key[i].ltk_key; i++) {
+       for ( i=MAXKEYS-1; i>=0; i--) {
+               if ( !ctx->ltu_key[i].ltk_key )
+                       continue;
                if ( ctx->ltu_key[i].ltk_free )
                        ctx->ltu_key[i].ltk_free( ctx->ltu_key[i].ltk_key,
                        ctx->ltu_key[i].ltk_data );