aboutsummaryrefslogtreecommitdiff
path: root/src/lib
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
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')
-rw-r--r--src/lib/evloop/workqueue.c8
-rw-r--r--src/lib/evloop/workqueue.h1
2 files changed, 9 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;
+}
diff --git a/src/lib/evloop/workqueue.h b/src/lib/evloop/workqueue.h
index 50391759bf..134fe7434f 100644
--- a/src/lib/evloop/workqueue.h
+++ b/src/lib/evloop/workqueue.h
@@ -65,5 +65,6 @@ void replyqueue_process(replyqueue_t *queue);
int threadpool_register_reply_event(threadpool_t *tp,
void (*cb)(threadpool_t *tp));
+unsigned int threadpool_get_n_threads(threadpool_t *tp);
#endif /* !defined(TOR_WORKQUEUE_H) */