commit 3b9d072a042968200ae9541855011cac29739083
parent d6887404a4f05dc611ba0cd145c58316ffbabc8a
Author: David Goulet <dgoulet@torproject.org>
Date: Mon, 31 Mar 2025 13:32:28 -0400
Merge branch 'maint-0.4.8'
Diffstat:
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/app/main/main.c b/src/app/main/main.c
@@ -1295,7 +1295,8 @@ run_tor_main_loop(void)
/* launch cpuworkers. Need to do this *after* we've read the onion key. */
/* launch them always for all tors, now that clients can solve onion PoWs. */
- cpuworker_init();
+ if (cpuworker_init() == -1)
+ return -1;
consdiffmgr_enable_background_compression();
diff --git a/src/core/mainloop/cpuworker.c b/src/core/mainloop/cpuworker.c
@@ -113,10 +113,8 @@ cpuworker_consensus_has_changed(const networkstatus_t *ns)
set_max_pending_tasks(ns);
}
-/** Initialize the cpuworker subsystem. It is OK to call this more than once
- * during Tor's lifetime.
- */
-void
+/** Initialize the cpuworker subsystem. */
+int
cpuworker_init(void)
{
/*
@@ -132,11 +130,18 @@ cpuworker_init(void)
worker_state_free_void,
NULL);
+ if (!threadpool) {
+ log_err(LD_GENERAL, "Can't create worker thread pool");
+ return -1;
+ }
+
int r = threadpool_register_reply_event(threadpool, NULL);
tor_assert(r == 0);
set_max_pending_tasks(NULL);
+
+ return 0;
}
/** Free all resources allocated by cpuworker. */
diff --git a/src/core/mainloop/cpuworker.h b/src/core/mainloop/cpuworker.h
@@ -12,7 +12,7 @@
#ifndef TOR_CPUWORKER_H
#define TOR_CPUWORKER_H
-void cpuworker_init(void);
+int cpuworker_init(void);
void cpuworker_free_all(void);
void cpuworkers_rotate_keyinfo(void);