Commit 1ce41b7f authored by Howard Chu's avatar Howard Chu
Browse files

ITS#4805 free thread keys in reverse order

parent 2429721f
......@@ -491,12 +491,7 @@ ldap_int_thread_pool_wrapper (
}
}
for ( i=0; i<MAXKEYS && ltc_key[i].ltk_key; i++ ) {
if (ltc_key[i].ltk_free)
ltc_key[i].ltk_free(
ltc_key[i].ltk_key,
ltc_key[i].ltk_data );
}
ldap_pvt_thread_pool_context_reset( ltc_key );
thread_keys[keyslot].ctx = NULL;
thread_keys[keyslot].id = tid_zero;
......@@ -602,7 +597,10 @@ int ldap_pvt_thread_pool_setkey(
for ( i=0; i<MAXKEYS; i++ ) {
if ( !ctx[i].ltk_key || ctx[i].ltk_key == key ) {
ctx[i].ltk_key = key;
if ( data || kfree )
ctx[i].ltk_key = key;
else
ctx[i].ltk_key = NULL;
ctx[i].ltk_data = data;
ctx[i].ltk_free = kfree;
return 0;
......@@ -665,7 +663,9 @@ void ldap_pvt_thread_pool_context_reset( void *vctx )
ldap_int_thread_key_t *ctx = vctx;
int i;
for ( i=0; i<MAXKEYS && ctx[i].ltk_key; i++) {
for ( i=MAXKEYS-1; i>=0; i--) {
if ( ctx[i].ltk_key )
continue;
if ( ctx[i].ltk_free )
ctx[i].ltk_free( ctx[i].ltk_key, ctx[i].ltk_data );
ctx[i].ltk_key = NULL;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment