aboutsummaryrefslogtreecommitdiff
path: root/crates/arti/src/subcommands
diff options
context:
space:
mode:
Diffstat (limited to 'crates/arti/src/subcommands')
-rw-r--r--crates/arti/src/subcommands/proxy.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/crates/arti/src/subcommands/proxy.rs b/crates/arti/src/subcommands/proxy.rs
index 95a10cdd4..17f480ae4 100644
--- a/crates/arti/src/subcommands/proxy.rs
+++ b/crates/arti/src/subcommands/proxy.rs
@@ -138,6 +138,9 @@ async fn run_proxy<R: ToplevelRuntime>(
false => BootstrapBehavior::OnDemand,
};
+ let (cfg_mgr, cfg_watcher_task) =
+ reload_cfg::CfgMgr::new(runtime.clone(), config_sources, &arti_config, vec![])?;
+
let client_builder = TorClient::with_runtime(runtime.clone())
.config(client_config)
.bootstrap_behavior(bootstrap_behavior);
@@ -172,18 +175,17 @@ async fn run_proxy<R: ToplevelRuntime>(
}
};
- // We weak references here to prevent the thread spawned by watch_for_config_changes from
+ // The add_module function will use references here
+ // to prevent the task spawned by watch_for_config_changes from
// keeping these modules alive after this function exits.
//
// NOTE: reconfigurable_modules stores the only strong references to these modules,
- // so we must keep the variable alive until the end of the function
- let weak_modules = reconfigurable_modules.iter().map(Arc::downgrade).collect();
- let _cfg_mgr = reload_cfg::CfgMgr::launch(
- client.runtime().clone(),
- config_sources,
- &arti_config,
- weak_modules,
- )?;
+ // so we must keep that variable alive until the end of the function
+ reconfigurable_modules
+ .iter()
+ .try_for_each(|m| cfg_watcher_task.add_module(m))?;
+
+ cfg_watcher_task.launch()?;
cfg_if::cfg_if! {
if #[cfg(feature = "rpc")] {
@@ -194,6 +196,7 @@ async fn run_proxy<R: ToplevelRuntime>(
&fs_mistrust,
client.clone(),
launchable_client.clone(),
+ cfg_mgr.clone(),
)
.await?;
let (rpc_mgr, mut rpc_state_sender) = rpc_data
@@ -322,8 +325,11 @@ async fn run_proxy<R: ToplevelRuntime>(
=> r.context("bootstrap"),
)?;
- // The modules can be dropped now, because we are exiting.
+ // The modules and CfgMgr can be dropped now, because we are exiting.
+ // (We drop them explicitly to make sure that they were not dropped
+ // accidentally before.)
drop(reconfigurable_modules);
+ drop(cfg_mgr);
Ok(())
}