diff --git a/iroh/src/node.rs b/iroh/src/node.rs index ad21b5b46f..fc9dc28634 100644 --- a/iroh/src/node.rs +++ b/iroh/src/node.rs @@ -21,7 +21,7 @@ use quic_rpc::{RpcServer, ServiceEndpoint}; use tokio::task::JoinSet; use tokio_util::sync::CancellationToken; use tokio_util::task::LocalPoolHandle; -use tracing::{debug, info, warn}; +use tracing::{debug, error, info, warn}; use crate::{ client::RpcService, @@ -274,7 +274,7 @@ impl NodeInner { request = external_rpc.accept() => { match request { Ok((msg, chan)) => { - rpc::Handler::spawn_rpc_request(self.clone(), &mut join_set, msg, chan); + rpc::Handler::spawn_rpc_request(self.clone(), msg, chan); } Err(e) => { info!("rpc request error: {:?}", e); @@ -285,7 +285,7 @@ impl NodeInner { request = internal_rpc.accept() => { match request { Ok((msg, chan)) => { - rpc::Handler::spawn_rpc_request(self.clone(), &mut join_set, msg, chan); + rpc::Handler::spawn_rpc_request(self.clone(), msg, chan); } Err(e) => { info!("internal rpc request error: {:?}", e); @@ -295,18 +295,17 @@ impl NodeInner { // handle incoming p2p connections. Some(connecting) = self.endpoint.accept() => { let protocols = protocols.clone(); - join_set.spawn(async move { + tokio::spawn(async move { handle_connection(connecting, protocols).await; - Ok(()) }); }, // handle task terminations and quit on panics. - // res = join_set.join_next(), if !join_set.is_empty() => { - // if let Some(Err(err)) = res { - // error!("Task failed: {err:?}"); - // break; - // } - // }, + res = join_set.join_next(), if !join_set.is_empty() => { + if let Some(Err(err)) = res { + error!("Task failed: {err:?}"); + break; + } + }, else => break, } } diff --git a/iroh/src/node/rpc.rs b/iroh/src/node/rpc.rs index 2c9b49fe38..2daf5a33a4 100644 --- a/iroh/src/node/rpc.rs +++ b/iroh/src/node/rpc.rs @@ -29,7 +29,6 @@ use quic_rpc::{ server::{RpcChannel, RpcServerError}, ServiceEndpoint, }; -use tokio::task::JoinSet; use tokio_util::{either::Either, task::LocalPoolHandle}; use tracing::{debug, info, warn}; @@ -108,16 +107,14 @@ impl Handler { pub(crate) fn spawn_rpc_request>( inner: Arc>, - join_set: &mut JoinSet>, msg: Request, chan: RpcChannel, ) { let handler = Self::new(inner); - join_set.spawn(async move { + tokio::spawn(async move { if let Err(err) = handler.handle_rpc_request(msg, chan).await { warn!("rpc request handler error: {err:?}"); } - Ok(()) }); }