mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-03-31 10:47:35 +03:00
check for WSAEMSGSIZE errors when receiving UDP packets on Windows (#3982)
* check for WSAEMSGSIZE errors when receiving UDP packets on Windows * check EMSGSIZE error on macOS
This commit is contained in:
parent
2183283622
commit
2bcfe5bc4b
6 changed files with 23 additions and 5 deletions
|
@ -82,7 +82,7 @@ func (h *sendQueue) Run() error {
|
|||
// 1. Checking for "datagram too large" message from the kernel, as such,
|
||||
// 2. Path MTU discovery,and
|
||||
// 3. Eventual detection of loss PingFrame.
|
||||
if !isMsgSizeErr(err) {
|
||||
if !isSendMsgSizeErr(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,12 @@ func setDF(syscall.RawConn) (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
func isMsgSizeErr(err error) bool {
|
||||
func isSendMsgSizeErr(err error) bool {
|
||||
// to be implemented for more specific platforms
|
||||
return false
|
||||
}
|
||||
|
||||
func isRecvMsgSizeErr(err error) bool {
|
||||
// to be implemented for more specific platforms
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -47,10 +47,12 @@ func setDF(rawConn syscall.RawConn) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func isMsgSizeErr(err error) bool {
|
||||
func isSendMsgSizeErr(err error) bool {
|
||||
return errors.Is(err, unix.EMSGSIZE)
|
||||
}
|
||||
|
||||
func isRecvMsgSizeErr(error) bool { return false }
|
||||
|
||||
func isAtLeastMacOS11() (bool, error) {
|
||||
uname := &unix.Utsname{}
|
||||
err := unix.Uname(uname)
|
||||
|
|
|
@ -57,11 +57,13 @@ func maybeSetGSO(rawConn syscall.RawConn) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func isMsgSizeErr(err error) bool {
|
||||
func isSendMsgSizeErr(err error) bool {
|
||||
// https://man7.org/linux/man-pages/man7/udp.7.html
|
||||
return errors.Is(err, unix.EMSGSIZE)
|
||||
}
|
||||
|
||||
func isRecvMsgSizeErr(err error) bool { return false }
|
||||
|
||||
func appendUDPSegmentSizeMsg(b []byte, size uint16) []byte {
|
||||
startLen := len(b)
|
||||
const dataLen = 2 // payload is a uint16
|
||||
|
|
|
@ -43,7 +43,12 @@ func setDF(rawConn syscall.RawConn) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func isMsgSizeErr(err error) bool {
|
||||
func isSendMsgSizeErr(err error) bool {
|
||||
// https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
|
||||
return errors.Is(err, windows.WSAEMSGSIZE)
|
||||
}
|
||||
|
||||
func isRecvMsgSizeErr(err error) bool {
|
||||
// https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
|
||||
return errors.Is(err, windows.WSAEMSGSIZE)
|
||||
}
|
||||
|
|
|
@ -330,6 +330,10 @@ func (t *Transport) listen(conn rawConn) {
|
|||
continue
|
||||
}
|
||||
if err != nil {
|
||||
// Windows returns an error when receiving a UDP datagram that doesn't fit into the provided buffer.
|
||||
if isRecvMsgSizeErr(err) {
|
||||
continue
|
||||
}
|
||||
t.close(err)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue