]> git.sur5r.net Git - openldap/commitdiff
Get rid of trivial yield, for completeness' sake.
authorHoward Chu <hyc@openldap.org>
Sun, 15 Jan 2006 14:34:44 +0000 (14:34 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 15 Jan 2006 14:34:44 +0000 (14:34 +0000)
libraries/libldap_r/tpool.c

index e23f9ad09cf8b252c31e89308af11490431b2a41..56e8f546878e635be19c9ae4dfc11c4f7051c60b 100644 (file)
@@ -508,14 +508,7 @@ ldap_pvt_thread_pool_destroy ( ldap_pvt_thread_pool_t *tpool, int run_pending )
                : LDAP_INT_THREAD_POOL_STOPPING;
 
        ldap_pvt_thread_cond_broadcast(&pool->ltp_cond);
-       ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);
-
-       do {
-               ldap_pvt_thread_yield();
-               ldap_pvt_thread_mutex_lock(&pool->ltp_mutex);
-               waiting = pool->ltp_open_count;
-               ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);
-       } while (waiting > 0);
+       ldap_pvt_thread_cond_wait(&pool->ltp_cond, &pool->ltp_mutex);
 
        while ((ctx = LDAP_STAILQ_FIRST(&pool->ltp_pending_list)) != NULL)
        {
@@ -645,6 +638,11 @@ ldap_int_thread_pool_wrapper (
        thread_keys[keyslot].id = tid_zero;
 
        pool->ltp_open_count--;
+
+       /* let pool_destroy know we're all done */
+       if (pool->ltp_open_count < 1)
+               ldap_pvt_thread_cond_signal(&pool->ltp_cond);
+
        ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);
 
        ldap_pvt_thread_exit(NULL);