aboutsummaryrefslogtreecommitdiff
path: root/src/or/cpuworker.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-07-12 12:23:33 -0400
committerNick Mathewson <nickm@torproject.org>2017-07-27 16:28:59 -0400
commit250c88014d81fcd4406359d44c9f3f3432844a2f (patch)
tree2a56693f0703f21ea7fe2a6265fb671c8c17655b /src/or/cpuworker.c
parent0ae0b5aa4136fe6df7863c8a5b7d239d519b7393 (diff)
downloadtor-250c88014d81fcd4406359d44c9f3f3432844a2f.tar.gz
tor-250c88014d81fcd4406359d44c9f3f3432844a2f.zip
Always start with one additional worker thread
Now that half the threads are permissive and half are strict, we need to make sure we have at least two threads, so that we'll have at least one of each kind.
Diffstat (limited to 'src/or/cpuworker.c')
-rw-r--r--src/or/cpuworker.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index ad99af64c0..8d71483f81 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -89,7 +89,14 @@ cpu_init(void)
event_add(reply_event, NULL);
}
if (!threadpool) {
- threadpool = threadpool_new(get_num_cpus(get_options()),
+ /*
+ In our threadpool implementation, half the threads are permissive and
+ half are strict (when it comes to running lower-priority tasks). So we
+ always make sure we have at least two threads, so that there will be at
+ least one thread of each kind.
+ */
+ const int n_threads = get_num_cpus(get_options()) + 1;
+ threadpool = threadpool_new(n_threads,
replyqueue,
worker_state_new,
worker_state_free,