From: よっキング <4476tv@gmail.com> Date: Sat, 27 Jun 2026 15:35:25 +0000 (+0900) Subject: Fixed listener loop dying on ChannelClosedException (#4) X-Git-Tag: 1.0.1~1 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=a93f71c702bad2aa23c99d32a7d50c2d2f373fc7;p=rhonda%2Fimpostor.hazel.git Fixed listener loop dying on ChannelClosedException (#4) * fix: Fixed an issue where all communications could not be processed due to ChannelClosedException. * fix: Change WriteAsync to TryWrite to make it safer. --- diff --git a/Hazel/Udp/UdpConnectionListener.cs b/Hazel/Udp/UdpConnectionListener.cs index 23c7a6a..2994b89 100644 --- a/Hazel/Udp/UdpConnectionListener.cs +++ b/Hazel/Udp/UdpConnectionListener.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using System.Net; using System.Net.Sockets; using System.Threading; +using System.Threading.Channels; using System.Threading.Tasks; using Microsoft.Extensions.ObjectPool; using Serilog; @@ -138,6 +139,7 @@ namespace Impostor.Hazel.Udp Logger.Fatal("Hazel read 0 bytes from UDP server socket."); continue; } + await ProcessData(data); } catch (SocketException) { @@ -149,8 +151,11 @@ namespace Impostor.Hazel.Udp // Socket was disposed, don't care. return; } - - await ProcessData(data); + catch (ChannelClosedException) + { + // Client closed, pretend it didn't happen + continue; + } } } catch (Exception e) @@ -191,7 +196,7 @@ namespace Impostor.Hazel.Udp } // Write to client. - await client.Pipeline.Writer.WriteAsync(data.Buffer); + client.Pipeline.Writer.TryWrite(data.Buffer); } ///