[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Free list not mutex protected in thread pool (ITS#1839)
Full_Name: Simon Wilkinson
Version: CVS HEAD / 2.1.1beta
OS: Linux
URL:
Submission from: (NULL) (62.6.94.189)
Additions to the thread pool free list in ldap_int_thread_pool_wrapper
(libldap_r/tpool.c:402) aren't protected by the per-pool mutex.
Whilst my understanding of this code is somewhat cursory, I believe that this
may lead to race conditions with the handling of the thread pool information.
The
fix, which seems to run correctly under Linux pthreads is:
--- tpool.c~ Tue Apr 2 23:57:53 2002
+++ tpool.c Mon May 27 11:31:42 2002
@@ -399,7 +399,11 @@
ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);
(ctx->ltc_start_routine)(ctx->ltc_arg);
+
+ ldap_pvt_thread_mutex_lock(&pool->ltp_mutex);
LDAP_SLIST_INSERT_HEAD(&pool->ltp_free_list, ctx, ltc_next.l);
+ ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);
+
ldap_pvt_thread_yield();
/* if we use an idle timer, here's