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>
This commit is contained in:
David Goulet
2022-11-23 13:47:59 -05:00
parent cca19a4099
commit fbc9e92fdb
6 changed files with 31 additions and 1 deletions
+8
View File
@@ -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;
}