From 372de00acaf151f44bd67176fdc693ccd874d8bd Mon Sep 17 00:00:00 2001 From: XOR-op <17672363+XOR-op@users.noreply.github.com> Date: Sat, 23 Nov 2024 23:51:00 -0500 Subject: [PATCH] fix(smol): stop udp futures and reclaim resources for closed sockets --- boltconn/src/transport/smol.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boltconn/src/transport/smol.rs b/boltconn/src/transport/smol.rs index b69f6ef..f8823ac 100644 --- a/boltconn/src/transport/smol.rs +++ b/boltconn/src/transport/smol.rs @@ -694,7 +694,8 @@ impl SmolStack { pub fn purge_timeout_udp(&mut self) { self.udp_conn.retain(|_port, task| { - if task.last_active.elapsed() > self.udp_timeout { + let socket = self.socket_set.get_mut::(task.handle); + if !socket.is_open() || task.last_active.elapsed() > self.udp_timeout { self.socket_set.remove(task.handle); task.abort_handle.cancel(); false