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.
This commit is contained in:
Roger Dingledine 2022-09-04 00:48:42 -04:00 committed by Micah Elizabeth Scott
parent 0716cd7cb2
commit a5b0c7b404
5 changed files with 9 additions and 14 deletions

View File

@ -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. */

View File

@ -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());

View File

@ -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);

View File

@ -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);

View File

@ -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);