[tor-commits] [tor/master] Impose an upper limit on threads per threadpool.

nickm at torproject.org nickm at torproject.org
Thu May 28 16:28:29 UTC 2015


commit a194385d5619f2b9c03ada34b8a7291ccc3c21ca
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu May 28 12:24:29 2015 -0400

    Impose an upper limit on threads per threadpool.
    
    Found by Coverity; Fixes CID 1268069
---
 src/common/workqueue.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/common/workqueue.c b/src/common/workqueue.c
index c1bd6d4..ed896d7 100644
--- a/src/common/workqueue.c
+++ b/src/common/workqueue.c
@@ -359,12 +359,17 @@ threadpool_queue_update(threadpool_t *pool,
   return 0;
 }
 
+/** Don't have more than this many threads per pool. */
+#define MAX_THREADS 1024
+
 /** Launch threads until we have <b>n</b>. */
 static int
 threadpool_start_threads(threadpool_t *pool, int n)
 {
   if (n < 0)
     return -1;
+  if (n > MAX_THREADS)
+    n = MAX_THREADS;
 
   tor_mutex_acquire(&pool->lock);
 





More information about the tor-commits mailing list