summaryrefslogtreecommitdiff
path: root/src/lib/evloop/workqueue.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-11-23 13:47:59 -0500
committerDavid Goulet <dgoulet@torproject.org>2022-11-23 14:05:10 -0500
commitfbc9e92fdb364a741a3190fc22c6fa65d90e92e3 (patch)
tree83f00a66b54dc942743811d0ea6a206a653a8686 /src/lib/evloop/workqueue.c
parentcca19a40991f1b6df7586b5c9f5491989ee54bca (diff)
downloadtor-fbc9e92fdb364a741a3190fc22c6fa65d90e92e3.tar.gz
tor-fbc9e92fdb364a741a3190fc22c6fa65d90e92e3.zip
relay: Use the configured number of threads for worker work calculation
We cap our number of CPU worker threads to at least 2 even if we have a single core. But also, before we used to always add one extra thread regardless of the number of core. This meant that we were off when re-using the get_num_cpus() function when calculating our onionskin work overhead because we were always off by one. This commit makes it that we always use the number of thread our actual thread pool was configured with. Fixes #40719 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/lib/evloop/workqueue.c')
-rw-r--r--src/lib/evloop/workqueue.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/evloop/workqueue.c b/src/lib/evloop/workqueue.c
index 603dddd5a3..bc929148eb 100644
--- a/src/lib/evloop/workqueue.c
+++ b/src/lib/evloop/workqueue.c
@@ -672,3 +672,11 @@ replyqueue_process(replyqueue_t *queue)
tor_mutex_release(&queue->lock);
}
+
+/** Return the number of threads configured for the given pool. */
+unsigned int
+threadpool_get_n_threads(threadpool_t *tp)
+{
+ tor_assert(tp);
+ return tp->n_threads;
+}