mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 11:57:39 +03:00
Fix syscall packet read waiter for Windows
This commit is contained in:
parent
9eafc7fc62
commit
d54716612c
1 changed files with 7 additions and 7 deletions
|
@ -120,16 +120,16 @@ func (w *syscallPacketReadWaiter) InitializeReadWaiter(options N.ReadWaitOptions
|
||||||
var readN int
|
var readN int
|
||||||
var from windows.Sockaddr
|
var from windows.Sockaddr
|
||||||
readN, from, w.readErr = windows.Recvfrom(windows.Handle(fd), buffer.FreeBytes(), 0)
|
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 {
|
if readN > 0 {
|
||||||
buffer.Truncate(readN)
|
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 {
|
if from != nil {
|
||||||
switch fromAddr := from.(type) {
|
switch fromAddr := from.(type) {
|
||||||
case *windows.SockaddrInet4:
|
case *windows.SockaddrInet4:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue