]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap_r/thr_debug.c
Merge remote branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / libldap_r / thr_debug.c
index 4decfa9622875053c94b1013b129400242bf396e..6d6307263cbf7b0d95c5d1e0fa9b532a01c77a63 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2005-2008 The OpenLDAP Foundation.
+ * Copyright 2005-2012 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -481,6 +481,7 @@ debug_noop( void )
  *
  * 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 )
 {
@@ -555,18 +556,21 @@ add_thread_info(
        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;
@@ -779,6 +783,7 @@ ldap_pvt_thread_create(
        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 ) );
@@ -843,6 +848,7 @@ ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
                                remove_thread_info( t, "ldap_pvt_thread_join" ) );
                adjust_count( Idx_unjoined_thread, -1 );
        }
+
        return rc;
 }