Un-Arc<> TorClient in the arti crate

TorClient doesn't need to be wrapped in an Arc any longer, thanks
to other refactoring.
This commit is contained in:
Nick Mathewson 2022-02-01 14:39:13 -05:00
parent feab848509
commit 610ccb3040
2 changed files with 5 additions and 8 deletions

View File

@ -92,8 +92,6 @@ mod process;
mod proxy;
mod trace;
use std::sync::Arc;
use arti_client::{TorClient, TorClientConfig};
use arti_config::{default_config_file, ArtiConfig};
use tor_rtcompat::{BlockOn, Runtime};
@ -112,11 +110,10 @@ async fn run<R: Runtime>(
futures::select!(
r = exit::wait_for_ctrl_c().fuse() => r,
r = async {
let client =
Arc::new(TorClient::bootstrap(
let client = TorClient::bootstrap(
runtime.clone(),
client_config,
).await?);
).await?;
proxy::run_socks_proxy(runtime, client, socks_port).await
}.fuse() => r,
)

View File

@ -106,7 +106,7 @@ impl IsolationMap {
/// id and the source address for the socks request.
async fn handle_socks_conn<R, S>(
runtime: R,
tor_client: Arc<TorClient<R>>,
tor_client: TorClient<R>,
socks_stream: S,
isolation_map: Arc<IsolationMap>,
isolation_info: (usize, IpAddr),
@ -388,7 +388,7 @@ fn accept_err_is_fatal(err: &IoError) -> bool {
/// network.
pub(crate) async fn run_socks_proxy<R: Runtime>(
runtime: R,
tor_client: Arc<TorClient<R>>,
tor_client: TorClient<R>,
socks_port: u16,
) -> Result<()> {
let mut listeners = Vec::new();
@ -443,7 +443,7 @@ pub(crate) async fn run_socks_proxy<R: Runtime>(
}
}
};
let client_ref = Arc::clone(&tor_client);
let client_ref = tor_client.clone();
let runtime_copy = runtime.clone();
let isolation_map_ref = Arc::clone(&isolation_map);
runtime.spawn(async move {