Skip to content

Commit def8ee1

Browse files
add send timeout to the relay actor
1 parent 3bec867 commit def8ee1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

iroh/src/magicsock/relay_actor.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,15 +641,19 @@ impl ActiveRelayActor {
641641
state: &mut ConnectedRelayState,
642642
client_stream: &mut iroh_relay::client::ClientStream,
643643
) -> Result<()> {
644-
// TODO
645-
// let mut timeout = pin!(tokio::time::sleep())
644+
const SEND_TIMEOUT: Duration = Duration::from_secs(10); // TODO: what should this be?
645+
646+
let mut timeout = pin!(tokio::time::sleep(SEND_TIMEOUT));
646647
let mut sending_fut = pin!(sending_fut);
647648
loop {
648649
tokio::select! {
649650
biased;
650651
_ = self.stop_token.cancelled() => {
651652
break Ok(());
652653
}
654+
_ = &mut timeout => {
655+
break Err(anyhow!("Send timeout"));
656+
}
653657
msg = self.prio_inbox.recv() => {
654658
let Some(msg) = msg else {
655659
warn!("Priority inbox closed, shutdown.");

0 commit comments

Comments
 (0)