Skip to content

Commit

Permalink
add send timeout to the relay actor
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jan 13, 2025
1 parent 0d7a933 commit 75c578a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions iroh/src/magicsock/relay_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,15 +641,19 @@ impl ActiveRelayActor {
state: &mut ConnectedRelayState,
client_stream: &mut iroh_relay::client::ClientStream,
) -> Result<()> {
// TODO
// let mut timeout = pin!(tokio::time::sleep())
const SEND_TIMEOUT: Duration = Duration::from_secs(10); // TODO: what should this be?

let mut timeout = pin!(tokio::time::sleep(SEND_TIMEOUT));
let mut sending_fut = pin!(sending_fut);
loop {
tokio::select! {
biased;
_ = self.stop_token.cancelled() => {
break Ok(());
}
_ = &mut timeout => {
break Err(anyhow!("Send timeout"));
}
msg = self.prio_inbox.recv() => {
let Some(msg) = msg else {
warn!("Priority inbox closed, shutdown.");
Expand Down

0 comments on commit 75c578a

Please sign in to comment.