From 41e86521b738b39eed0d3c1bd7b8d400046bc083 Mon Sep 17 00:00:00 2001 From: Datong Sun Date: Sat, 9 Oct 2021 09:22:20 -0700 Subject: [PATCH] fix(fake-tcp) more robust checking for receiving end closing, avoids panicking tasks from causing server to stop completely --- fake-tcp/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fake-tcp/src/lib.rs b/fake-tcp/src/lib.rs index eb7a5ba..a1ef0c9 100644 --- a/fake-tcp/src/lib.rs +++ b/fake-tcp/src/lib.rs @@ -385,9 +385,15 @@ impl Stack { let tuple = AddrTuple::new(local_addr, remote_addr); if let Some(c) = tuples.get(&tuple) { - c.send(buf).await.unwrap(); + if c.send(buf).await.is_err() { + trace!("Cache hit, but receiver already closed, dropping packet"); + } + continue; + // If not Ok, receiver has been closed and just fall through to the slow + // path below + } else { trace!("Cache miss, checking the shared tuples table for connection"); let sender;