diff --git a/prototypes/ptth_quic_client_gui/src/main.rs b/prototypes/ptth_quic_client_gui/src/main.rs index cc9ad6f..371195c 100644 --- a/prototypes/ptth_quic_client_gui/src/main.rs +++ b/prototypes/ptth_quic_client_gui/src/main.rs @@ -66,7 +66,13 @@ impl GuiClient <'_> { pub fn close_port (&mut self, port_idx: usize) -> anyhow::Result <()> { if let Some (old_instance) = self.forwarding_instances [port_idx].take () { - self.rt.block_on (old_instance.close ())?; + self.rt.block_on (async { + old_instance.close () + .await + .context ("closing ForwardingInstance")?; + + Ok::<_, anyhow::Error> (()) + })?; } self.gui_ports [port_idx].set_forwarding (false); diff --git a/prototypes/quic_demo/src/client_proxy.rs b/prototypes/quic_demo/src/client_proxy.rs index 8780efc..87035e4 100644 --- a/prototypes/quic_demo/src/client_proxy.rs +++ b/prototypes/quic_demo/src/client_proxy.rs @@ -32,8 +32,13 @@ impl ForwardingInstance { } pub async fn close (self) -> anyhow::Result <()> { - self.shutdown_flag.send (false)?; - self.task.await??; + match self.shutdown_flag.send (false) { + Err (_) => warn! ("Trying to gracefully shutdown forwarding task but it appears to already be shut down"), + _ => (), + } + self.task.await + .context ("awaiting ForwardingInstance task")? + .context ("inside ForwardingInstance task")?; Ok (()) } }