Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Nov 27, 2024
1 parent f1f2aac commit 3f2c8b9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,21 +485,20 @@ impl Context {

/// Stops the IO scheduler.
pub async fn stop_io(&self) {
self.scheduler.stop(self).await;
if let Some(iroh) = self.iroh.write().await.take() {
// Close all QUIC connections.
let ctx = self.clone();

// Spawn into a separate task,
// because Iroh calls `wait_idle()` internally
// and it may take time, especially if the network
// has become unavailable.
tokio::spawn(async move {
if let Err(err) = iroh.close().await {
warn!(ctx, "Failed to close Iroh: {err:#}.");
}
// We do not log the error because we do not want the task
// to hold the reference to Context.
let _ = tokio::time::timeout(Duration::from_secs(60), iroh.close()).await;
});
}
self.scheduler.stop(self).await;
}

/// Restarts the IO scheduler if it was running before
Expand Down

0 comments on commit 3f2c8b9

Please sign in to comment.