From 9e9bf22a64343e63cda1d0b69679057628c007db Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Wed, 9 May 2007 19:34:49 +0000 Subject: [PATCH] ITS#4943: In ldap_pvt_thread_pool_submit(), when backing out of thread creation: ltp_pending_count '++' -> '--'. Signal if there are no more threads. In ldap_int_thread_pool_wrapper(): if() -> assert() where false would result in eternal loop. --- libraries/libldap_r/tpool.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/libldap_r/tpool.c b/libraries/libldap_r/tpool.c index 1c564e37a5..20df9a862f 100644 --- a/libraries/libldap_r/tpool.c +++ b/libraries/libldap_r/tpool.c @@ -417,6 +417,10 @@ ldap_pvt_thread_pool_submit ( /* no open threads at all?!? */ ldap_int_thread_ctx_t *ptr; + + /* let pool_destroy know there are no more threads */ + ldap_pvt_thread_cond_signal(&pool->ltp_cond); + LDAP_STAILQ_FOREACH(ptr, &pool->ltp_pending_list, ltc_next.q) if (ptr == ctx) break; if (ptr == ctx) { @@ -426,7 +430,7 @@ ldap_pvt_thread_pool_submit ( */ LDAP_STAILQ_REMOVE(&pool->ltp_pending_list, ctx, ldap_int_thread_ctx_s, ltc_next.q); - pool->ltp_pending_count++; + pool->ltp_pending_count--; ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex); LDAP_FREE(ctx); return(-1); @@ -686,12 +690,9 @@ ldap_int_thread_pool_wrapper ( * check idle time. */ - if (pool->ltp_state == LDAP_INT_THREAD_POOL_RUNNING - || pool->ltp_state == LDAP_INT_THREAD_POOL_PAUSING) - { - ldap_pvt_thread_cond_wait(&pool->ltp_cond, &pool->ltp_mutex); - } - + assert(pool->ltp_state == LDAP_INT_THREAD_POOL_RUNNING + || pool->ltp_state == LDAP_INT_THREAD_POOL_PAUSING); + ldap_pvt_thread_cond_wait(&pool->ltp_cond, &pool->ltp_mutex); continue; } -- 2.39.5