Perform a clean shutdown in case worker threads cannot be lauched.
/* 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();
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)
{
/*
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. */
#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);