]> git.sur5r.net Git - openldap/commitdiff
More for 6853, add condvar for end condition
authorHoward Chu <hyc@openldap.org>
Fri, 11 Mar 2011 22:16:13 +0000 (22:16 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 11 Mar 2011 22:16:13 +0000 (22:16 +0000)
servers/slapd/back-bdb/tools.c

index 94efeae0abed5ead904f4d65990211128244310a..18bbeeeb3543063b6bf36c66557c0f8a52e4a7aa 100644 (file)
@@ -90,6 +90,7 @@ static ldap_pvt_thread_cond_t bdb_tool_index_cond_work;
 #ifdef USE_TRICKLE
 static ldap_pvt_thread_mutex_t bdb_tool_trickle_mutex;
 static ldap_pvt_thread_cond_t bdb_tool_trickle_cond;
+static ldap_pvt_thread_cond_t bdb_tool_trickle_cond_end;
 
 static void * bdb_tool_trickle_task( void *ctx, void *ptr );
 static int bdb_tool_trickle_active;
@@ -128,6 +129,7 @@ int bdb_tool_entry_open(
 #ifdef USE_TRICKLE
                        ldap_pvt_thread_mutex_init( &bdb_tool_trickle_mutex );
                        ldap_pvt_thread_cond_init( &bdb_tool_trickle_cond );
+                       ldap_pvt_thread_cond_init( &bdb_tool_trickle_cond_end );
                        ldap_pvt_thread_pool_submit( &connection_pool, bdb_tool_trickle_task, bdb->bi_dbenv );
 #endif
 
@@ -161,10 +163,8 @@ int bdb_tool_entry_close(
 #ifdef USE_TRICKLE
                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,
+                       ldap_pvt_thread_cond_wait( &bdb_tool_trickle_cond_end,
                                        &bdb_tool_trickle_mutex );
                ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex );
 #endif
@@ -1264,7 +1264,7 @@ bdb_tool_trickle_task( void *ctx, void *ptr )
                env->memp_trickle( env, 30, &wrote );
        }
        bdb_tool_trickle_active = 0;
-       ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond );
+       ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond_end );
        ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex );
 
        return NULL;