mirror of
https://github.com/golang/go
synced 2024-11-21 21:34:40 -07:00
internal/poll: disable SIO_UDP_NETRESET on Windows
Windows UDP sockets have novel behavior in response to ICMP, where by
default RecvFrom will receive a read error as a result of an incoming
ICMP packet. This behavior is not portable or consistent with behavior
on other platforms, so for consistency it is disabled here.
This is similar to, but a different case from the prior change 3114bd6
/
https://golang.org/issue/5834 that disabled one of the two flags
influencing behavior in response to the reception of related ICMP.
Updates #5834
Updates #68614
This commit is contained in:
parent
9e40780a46
commit
ab6ab507fc
@ -337,8 +337,8 @@ func (fd *FD) Init(net string, pollable bool) (string, error) {
|
|||||||
fd.skipSyncNotif = true
|
fd.skipSyncNotif = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Disable SIO_UDP_CONNRESET behavior.
|
// Disable SIO_UDP_CONNRESET and SIO_UDP_NETRESET behavior.
|
||||||
// http://support.microsoft.com/kb/263823
|
// http://support.microsoft.com/kb/263823 / https://golang.org/issue/68614
|
||||||
switch net {
|
switch net {
|
||||||
case "udp", "udp4", "udp6":
|
case "udp", "udp4", "udp6":
|
||||||
ret := uint32(0)
|
ret := uint32(0)
|
||||||
@ -348,6 +348,14 @@ func (fd *FD) Init(net string, pollable bool) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "wsaioctl", err
|
return "wsaioctl", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret := uint32(0)
|
||||||
|
flag := uint32(0)
|
||||||
|
size := uint32(unsafe.Sizeof(flag))
|
||||||
|
err := syscall.WSAIoctl(fd.Sysfd, syscall.SIO_UDP_NETRESET, (*byte)(unsafe.Pointer(&flag)), size, nil, 0, &ret, nil, 0)
|
||||||
|
if err != nil {
|
||||||
|
return "wsaioctl", err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fd.rop.mode = 'r'
|
fd.rop.mode = 'r'
|
||||||
fd.wop.mode = 'w'
|
fd.wop.mode = 'w'
|
||||||
|
Loading…
Reference in New Issue
Block a user