From f7b370ba82e028e4aebe5f3e1abcf65c68ee8ef0 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Mon, 3 Aug 2026 00:28:39 -0400 Subject: [PATCH] Share control request timeout --- src/iroh.rs | 6 +++--- src/iroh/handler.rs | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/iroh.rs b/src/iroh.rs index fd0d2cf..055fa36 100644 --- a/src/iroh.rs +++ b/src/iroh.rs @@ -32,7 +32,7 @@ pub const APPA_ALPN: &[u8] = b"appa/sync/3"; const MAX_CONTROL_MESSAGE_BYTES: usize = 16 * 1024 * 1024; const MAX_CONCURRENT_ANNOUNCEMENTS: usize = 4; const ANNOUNCEMENT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(5); -const CONTROL_OPERATION_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); +pub(super) const CONTROL_REQUEST_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); const BLOB_OPERATION_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(5 * 60); const ONLINE_WAIT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30); const BLOB_ACTIVITY_EVENT_BUFFER: usize = 32; @@ -402,7 +402,7 @@ impl NodeHost { async fn connect_to_peer(&self, peer_address: EndpointAddr) -> anyhow::Result { let connection = tokio::time::timeout( - CONTROL_OPERATION_TIMEOUT, + CONTROL_REQUEST_TIMEOUT, self.endpoint.connect(peer_address.clone(), APPA_ALPN), ) .await @@ -511,7 +511,7 @@ async fn request_control_message( if payload.len() > MAX_CONTROL_MESSAGE_BYTES { anyhow::bail!("control message exceeds the maximum size"); } - tokio::time::timeout(CONTROL_OPERATION_TIMEOUT, async { + tokio::time::timeout(CONTROL_REQUEST_TIMEOUT, async { let (mut send, mut receive) = connection.open_bi().await?; send.write_all(&payload).await?; send.finish()?; diff --git a/src/iroh/handler.rs b/src/iroh/handler.rs index 0b70797..4ad16ed 100644 --- a/src/iroh/handler.rs +++ b/src/iroh/handler.rs @@ -1,7 +1,6 @@ use std::{ collections::BTreeMap, sync::{Arc, Mutex}, - time::Duration, }; use iroh::{ @@ -13,12 +12,10 @@ use tokio::sync::RwLock; use crate::{ domain::FolderId, - iroh::{DiscoveredPeer, HostedFolder, MAX_CONTROL_MESSAGE_BYTES}, + iroh::{CONTROL_REQUEST_TIMEOUT, DiscoveredPeer, HostedFolder, MAX_CONTROL_MESSAGE_BYTES}, protocol::{ControlMessage, ManifestRequestKind, ManifestSummary, validate_invite}, }; -const CONTROL_REQUEST_TIMEOUT: Duration = Duration::from_secs(10); - #[derive(Clone, Debug)] pub(super) struct AppaProtocol { pub(super) folders: Arc>>, -- 2.51.2