From 8f6d7a5f20814734d890b117d53b49e4bee410ba Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Fri, 30 Dec 2022 10:15:42 -0600 Subject: [PATCH] Deal with closing the named pipe while a write is in progress (hung clients) --- OTDIPC/Server.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OTDIPC/Server.cs b/OTDIPC/Server.cs index 6081e5d..7e01abf 100644 --- a/OTDIPC/Server.cs +++ b/OTDIPC/Server.cs @@ -53,6 +53,12 @@ public void SendMessage(T message) where T : struct { OnFailedWrite(); } + catch (ObjectDisposedException) { + // If we think the client's hung, we can close the connection + // while a write is in progress; this is especially common + // for ping writes. + OnFailedWrite(); + } finally { Marshal.FreeCoTaskMem(ptr);