Add ldap_pvt_thread_pool_purgekey to free all instances of key across

all threads.
This commit is contained in:
Howard Chu 2005-04-22 22:27:29 +00:00
parent 838421f416
commit 3f20324ed0
2 changed files with 27 additions and 0 deletions

View file

@ -202,6 +202,9 @@ ldap_pvt_thread_pool_setkey LDAP_P((
void *data,
ldap_pvt_thread_pool_keyfree_t *kfree ));
LDAP_F( void )
ldap_pvt_thread_pool_purgekey LDAP_P(( void *key ));
LDAP_F( void *)
ldap_pvt_thread_pool_context LDAP_P(( void ));

View file

@ -616,6 +616,30 @@ int ldap_pvt_thread_pool_setkey(
return ENOMEM;
}
/* Free all elements with this key, no matter which thread they're in.
* May only be called while the pool is paused.
*/
void ldap_pvt_thread_pool_purgekey( void *key )
{
int i, j;
ldap_int_thread_key_t *ctx;
for ( i=0; i<LDAP_MAXTHR; i++ ) {
if ( thread_keys[i].ctx ) {
ctx = thread_keys[i].ctx;
for ( j=0; j<MAXKEYS; j++ ) {
if ( ctx[j].ltk_key == key ) {
if (ctx[j].ltk_free)
ctx[j].ltk_free( ctx[j].ltk_key, ctx[j].ltk_data );
ctx[j].ltk_key = NULL;
ctx[j].ltk_free = NULL;
break;
}
}
}
}
}
/*
* This is necessary if the caller does not have access to the
* thread context handle (for example, a slapd plugin calling