]> git.sur5r.net Git - openldap/commitdiff
ITS#4943:
authorHallvard Furuseth <hallvard@openldap.org>
Wed, 9 May 2007 19:34:49 +0000 (19:34 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Wed, 9 May 2007 19:34:49 +0000 (19:34 +0000)
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

index 1c564e37a596dc28d362557121c567e1d7613f72..20df9a862fd2b4d96e5e3a00a70317448dab1189 100644 (file)
@@ -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;
                }