From: Howard Chu Date: Fri, 4 Mar 2011 23:54:10 +0000 (+0000) Subject: ITS#6853 wait for trickle task to quit X-Git-Tag: MIGRATION_CVS2GIT~33 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7dd1089706fdfc23a649a159ed2319e102601db2;p=openldap ITS#6853 wait for trickle task to quit --- diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index e3776dbe59..94efeae0ab 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -92,6 +92,7 @@ static ldap_pvt_thread_mutex_t bdb_tool_trickle_mutex; static ldap_pvt_thread_cond_t bdb_tool_trickle_cond; static void * bdb_tool_trickle_task( void *ctx, void *ptr ); +static int bdb_tool_trickle_active; #endif static void * bdb_tool_index_task( void *ctx, void *ptr ); @@ -161,6 +162,11 @@ int bdb_tool_entry_close( ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex ); ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond ); ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex ); + ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex ); + while ( bdb_tool_trickle_active ) + ldap_pvt_thread_cond_wait( &bdb_tool_trickle_cond, + &bdb_tool_trickle_mutex ); + ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex ); #endif ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex ); @@ -1249,6 +1255,7 @@ bdb_tool_trickle_task( void *ctx, void *ptr ) int wrote; ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex ); + bdb_tool_trickle_active = 1; while ( 1 ) { ldap_pvt_thread_cond_wait( &bdb_tool_trickle_cond, &bdb_tool_trickle_mutex ); @@ -1256,6 +1263,8 @@ bdb_tool_trickle_task( void *ctx, void *ptr ) break; env->memp_trickle( env, 30, &wrote ); } + bdb_tool_trickle_active = 0; + ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond ); ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex ); return NULL;