/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2005-2007 The OpenLDAP Foundation.
+ * Copyright 2005-2012 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
*
* Run-time configuration:
*
- * Setup of memory debugging tools:
+ * Memory debugging tools:
* Tools that report uninitialized memory accesses should disable
* such warnings about the function debug_already_initialized().
* Alternatively, include "noreinit" (below) in $LDAP_THREAD_DEBUG.
*
* Returns true if the resource is initialized and not copied/realloced.
*/
+LDAP_GCCATTR((noinline))
static int
debug_already_initialized( const ldap_debug_usage_info_t *usage )
{
int detached )
{
ldap_debug_thread_t *t;
+
if( thread_info_used >= thread_info_size ) {
unsigned int more = thread_info_size + 8;
unsigned int new_size = thread_info_size + more;
+
t = calloc( more, sizeof(ldap_debug_thread_t) );
assert( t != NULL );
thread_info = realloc( thread_info, new_size * sizeof(*thread_info) );
assert( thread_info != NULL );
- while( thread_info_size < new_size ) {
+ do {
t->idx = thread_info_size;
thread_info[thread_info_size++] = t++;
- }
+ } while( thread_info_size < new_size );
}
+
t = thread_info[thread_info_used];
init_usage( &t->usage, msg );
t->wrapped = *thread;
(thread_info[thread_info_used] = t )->idx = thread_info_used;
}
-ldap_debug_thread_t *
+static ldap_debug_thread_t *
get_thread_info( ldap_pvt_thread_t thread, const char *msg )
{
unsigned int i;
if( !options_done )
get_options();
ERROR_IF( !threading_enabled, "ldap_pvt_thread_create" );
+
if( wrap_threads ) {
ldap_debug_thread_call_t *call = malloc(
sizeof( ldap_debug_thread_call_t ) );
remove_thread_info( t, "ldap_pvt_thread_join" ) );
adjust_count( Idx_unjoined_thread, -1 );
}
+
return rc;
}
{
int rc, has_pool;
ERROR_IF( !threading_enabled, "ldap_pvt_thread_pool_submit" );
- has_pool = (tpool != NULL && *tpool != NULL);
+ has_pool = (tpool && *tpool);
rc = ldap_int_thread_pool_submit( tpool, start_routine, arg );
if( has_pool )
ERROR_IF( rc, "ldap_pvt_thread_pool_submit" );
{
int rc, has_pool;
ERROR_IF( !threading_enabled, "ldap_pvt_thread_pool_destroy" );
- has_pool = (tpool != NULL && *tpool != NULL);
+ has_pool = (tpool && *tpool);
rc = ldap_int_thread_pool_destroy( tpool, run_pending );
if( has_pool ) {
if( rc ) {
void *xctx,
void *key,
void *data,
- ldap_pvt_thread_pool_keyfree_t *kfree )
+ ldap_pvt_thread_pool_keyfree_t *kfree,
+ void **olddatap,
+ ldap_pvt_thread_pool_keyfree_t **oldkfreep )
{
int rc;
ERROR_IF( !threading_enabled, "ldap_pvt_thread_pool_setkey" );
- rc = ldap_int_thread_pool_setkey( xctx, key, data, kfree );
+ rc = ldap_int_thread_pool_setkey(
+ xctx, key, data, kfree, olddatap, oldkfreep );
ERROR_IF( rc, "ldap_pvt_thread_pool_setkey" );
return rc;
}