From d54716612ceee75a28d728e9c682bf6e926b2056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 28 Feb 2025 12:06:56 +0800 Subject: [PATCH] Fix syscall packet read waiter for Windows --- common/bufio/copy_direct_windows.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/bufio/copy_direct_windows.go b/common/bufio/copy_direct_windows.go index 482b649..7da9213 100644 --- a/common/bufio/copy_direct_windows.go +++ b/common/bufio/copy_direct_windows.go @@ -120,16 +120,16 @@ func (w *syscallPacketReadWaiter) InitializeReadWaiter(options N.ReadWaitOptions var readN int var from windows.Sockaddr readN, from, w.readErr = windows.Recvfrom(windows.Handle(fd), buffer.FreeBytes(), 0) + //goland:noinspection GoDirectComparisonOfErrors + if w.readErr != nil { + buffer.Release() + return w.readErr != windows.WSAEWOULDBLOCK + } if readN > 0 { buffer.Truncate(readN) - w.options.PostReturn(buffer) - w.buffer = buffer - } else { - buffer.Release() - } - if w.readErr == windows.WSAEWOULDBLOCK { - return false } + w.options.PostReturn(buffer) + w.buffer = buffer if from != nil { switch fromAddr := from.(type) { case *windows.SockaddrInet4: