mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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:
@@ -144,6 +144,16 @@ cpu_init(void)
|
||||
set_max_pending_tasks(NULL);
|
||||
}
|
||||
|
||||
/** Return the number of threads configured for our CPU worker. */
|
||||
unsigned int
|
||||
cpuworker_get_n_threads(void)
|
||||
{
|
||||
if (!threadpool) {
|
||||
return 0;
|
||||
}
|
||||
return threadpool_get_n_threads(threadpool);
|
||||
}
|
||||
|
||||
/** Magic numbers to make sure our cpuworker_requests don't grow any
|
||||
* mis-framing bugs. */
|
||||
#define CPUWORKER_REQUEST_MAGIC 0xda4afeed
|
||||
|
||||
@@ -38,5 +38,7 @@ void cpuworker_log_onionskin_overhead(int severity, int onionskin_type,
|
||||
const char *onionskin_type_name);
|
||||
void cpuworker_cancel_circ_handshake(or_circuit_t *circ);
|
||||
|
||||
unsigned int cpuworker_get_n_threads(void);
|
||||
|
||||
#endif /* !defined(TOR_CPUWORKER_H) */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user