From: Howard Chu Date: Wed, 3 May 2006 07:41:12 +0000 (+0000) Subject: Remove some more yield() calls X-Git-Tag: OPENLDAP_REL_ENG_2_4_1ALPHA~2^2~87 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2a5ecbccaa1592f596d10bce321701cc2aff35b1;p=openldap Remove some more yield() calls --- diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 167f3c7e5e..9c6e23ef7c 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -68,7 +68,8 @@ static int *bdb_tool_index_threads, bdb_tool_index_tcount; static void *bdb_tool_index_rec; static struct bdb_info *bdb_tool_info; static ldap_pvt_thread_mutex_t bdb_tool_index_mutex; -static ldap_pvt_thread_cond_t bdb_tool_index_cond; +static ldap_pvt_thread_cond_t bdb_tool_index_cond_main; +static ldap_pvt_thread_cond_t bdb_tool_index_cond_work; static void * bdb_tool_index_task( void *ctx, void *ptr ); @@ -98,7 +99,8 @@ int bdb_tool_entry_open( if ( !bdb_tool_info ) { int i; ldap_pvt_thread_mutex_init( &bdb_tool_index_mutex ); - ldap_pvt_thread_cond_init( &bdb_tool_index_cond ); + ldap_pvt_thread_cond_init( &bdb_tool_index_cond_main ); + ldap_pvt_thread_cond_init( &bdb_tool_index_cond_work ); bdb_tool_index_threads = ch_malloc( slap_tool_thread_max * sizeof( int )); bdb_tool_index_rec = ch_malloc( bdb->bi_nattrs * sizeof( IndexRec )); bdb_tool_index_tcount = slap_tool_thread_max - 1; @@ -122,7 +124,7 @@ int bdb_tool_entry_close( slapd_shutdown = 1; ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex ); bdb_tool_index_tcount = slap_tool_thread_max - 1; - ldap_pvt_thread_cond_broadcast( &bdb_tool_index_cond ); + ldap_pvt_thread_cond_broadcast( &bdb_tool_index_cond_work ); ldap_pvt_thread_mutex_unlock( &bdb_tool_index_mutex ); } @@ -410,28 +412,32 @@ bdb_tool_index_add( ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex ); /* Wait for all threads to be ready */ while ( bdb_tool_index_tcount ) { - ldap_pvt_thread_mutex_unlock( &bdb_tool_index_mutex ); - ldap_pvt_thread_yield(); - ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex ); + ldap_pvt_thread_cond_wait( &bdb_tool_index_cond_main, + &bdb_tool_index_mutex ); } for ( i=1; ie_id, 0 ); if ( rc ) return rc; + ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex ); for ( i=1; i