diff --git a/iroh/src/node/builder.rs b/iroh/src/node/builder.rs index 48fac63723f..c43ca49e4ab 100644 --- a/iroh/src/node/builder.rs +++ b/iroh/src/node/builder.rs @@ -308,7 +308,7 @@ where self } - /// Disable documents support on this node completely. + /// Disables documents support on this node completely. pub fn disable_docs(mut self) -> Self { self.docs_store = None; self @@ -628,7 +628,10 @@ where ) { let server = inner.endpoint.clone(); let docs = protocols.get::(DOCS_ALPN); - let handler = rpc::Handler { inner, docs }; + let handler = rpc::Handler { + inner: inner.clone(), + docs, + }; let rpc = RpcServer::new(rpc); let internal_rpc = RpcServer::new(internal_rpc); let (ipv4, ipv6) = server.local_addr(); @@ -709,7 +712,9 @@ where } }; let protocols = protocols.clone(); - tokio::task::spawn(async move { + let mut tasks_guard = inner.tasks.lock().unwrap(); + let tasks = tasks_guard.as_mut().expect("only empty after shutdown"); + tasks.spawn(async move { if let Err(err) = handle_connection(connecting, alpn, protocols).await { warn!("Handling incoming connection ended with error: {err}"); } @@ -838,33 +843,6 @@ async fn handle_connection( } else { bail!("ignoring connection: unsupported ALPN protocol"); } - // match alpn.as_bytes() { - // GOSSIP_ALPN => gossip.handle_connection(connecting.await?).await?, - // DOCS_ALPN => sync.handle_connection(connecting).await?, - // iroh_blobs::protocol::ALPN => { - // let connection = connecting.await?; - // iroh_blobs::provider::handle_connection( - // connection, - // node.db.clone(), - // MockEventSender, - // node.rt.clone(), - // ) - // .await - // } - // alpn => { - // let protocol = { - // let protocols = protocols.read().unwrap(); - // protocols.get(alpn).cloned() - // }; - // if let Some(protocol) = protocol { - // drop(protocols); - // let connection = connecting.await?; - // protocol.accept(connection).await?; - // } else { - // bail!("ignoring connection: unsupported ALPN protocol"); - // } - // } - // } Ok(()) }