aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2022-09-04 00:48:42 -0400
committerMicah Elizabeth Scott <beth@torproject.org>2023-05-10 07:37:11 -0700
commita5b0c7b4045d02acc15375a7d8bbad727b36e0de (patch)
tree01858c7b45d0b8935d8e911ac334c953ce74f97c /src
parent0716cd7cb203f21876bf6fe1e1acdc438d8e2031 (diff)
downloadtor-a5b0c7b4045d02acc15375a7d8bbad727b36e0de.tar.gz
tor-a5b0c7b4045d02acc15375a7d8bbad727b36e0de.zip
start the cpuworkers always, even for clients
prepares the way for client-side pow cpuworkers also happens to resolve bug https://bugs.torproject.org/tpo/core/tor/40617 (which went into 0.4.7.4-alpha) because now we survive initing the cpuworker subsystem when we're not a relay.
Diffstat (limited to 'src')
-rw-r--r--src/app/main/main.c8
-rw-r--r--src/core/crypto/onion_crypto.c3
-rw-r--r--src/core/mainloop/cpuworker.c2
-rw-r--r--src/core/mainloop/cpuworker.h4
-rw-r--r--src/feature/relay/relay_config.c6
5 files changed, 9 insertions, 14 deletions
diff --git a/src/app/main/main.c b/src/app/main/main.c
index 838e129d04..a50a0aad6f 100644
--- a/src/app/main/main.c
+++ b/src/app/main/main.c
@@ -1237,10 +1237,10 @@ run_tor_main_loop(void)
const time_t now = time(NULL);
directory_info_has_arrived(now, 1, 0);
- if (server_mode(get_options()) || dir_server_mode(get_options())) {
- /* launch cpuworkers. Need to do this *after* we've read the onion key. */
- cpu_init();
- }
+ /* 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();
+
consdiffmgr_enable_background_compression();
/* Setup shared random protocol subsystem. */
diff --git a/src/core/crypto/onion_crypto.c b/src/core/crypto/onion_crypto.c
index 81e4e1b078..0839d8903f 100644
--- a/src/core/crypto/onion_crypto.c
+++ b/src/core/crypto/onion_crypto.c
@@ -64,6 +64,9 @@ static const size_t NTOR3_CIRC_VERIFICATION_LEN = 14;
server_onion_keys_t *
server_onion_keys_new(void)
{
+ if (!get_master_identity_key())
+ return NULL;
+
server_onion_keys_t *keys = tor_malloc_zero(sizeof(server_onion_keys_t));
memcpy(keys->my_identity, router_get_my_id_digest(), DIGEST_LEN);
ed25519_pubkey_copy(&keys->my_ed_identity, get_master_identity_key());
diff --git a/src/core/mainloop/cpuworker.c b/src/core/mainloop/cpuworker.c
index 9ad8939e4d..4a22790b44 100644
--- a/src/core/mainloop/cpuworker.c
+++ b/src/core/mainloop/cpuworker.c
@@ -117,7 +117,7 @@ cpuworker_consensus_has_changed(const networkstatus_t *ns)
* during Tor's lifetime.
*/
void
-cpu_init(void)
+cpuworker_init(void)
{
if (!replyqueue) {
replyqueue = replyqueue_new(0);
diff --git a/src/core/mainloop/cpuworker.h b/src/core/mainloop/cpuworker.h
index 9eee287c1f..7821f5612f 100644
--- a/src/core/mainloop/cpuworker.h
+++ b/src/core/mainloop/cpuworker.h
@@ -12,9 +12,7 @@
#ifndef TOR_CPUWORKER_H
#define TOR_CPUWORKER_H
-#include "feature/nodelist/networkstatus_st.h"
-
-void cpu_init(void);
+void cpuworker_init(void);
void cpuworkers_rotate_keyinfo(void);
void cpuworker_consensus_has_changed(const networkstatus_t *ns);
diff --git a/src/feature/relay/relay_config.c b/src/feature/relay/relay_config.c
index aa9d48beac..553b269ecf 100644
--- a/src/feature/relay/relay_config.c
+++ b/src/feature/relay/relay_config.c
@@ -1327,12 +1327,6 @@ options_act_relay(const or_options_t *old_options)
"Worker-related options changed. Rotating workers.");
const int server_mode_turned_on =
server_mode(options) && !server_mode(old_options);
- const int dir_server_mode_turned_on =
- dir_server_mode(options) && !dir_server_mode(old_options);
-
- if (server_mode_turned_on || dir_server_mode_turned_on) {
- cpu_init();
- }
if (server_mode_turned_on) {
ip_address_changed(0);