Skip to content

Commit 69158cf

Browse files
Merge pull request #2886 from lucas-clemente/fix-syscalls
only use syscalls on platforms that we're actually testing
2 parents a9f807c + 631e37c commit 69158cf

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

conn_ecn.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
// +build !windows
1+
// +build darwin linux
22

33
package quic
44

55
import (
66
"errors"
7+
"fmt"
8+
"net"
79
"syscall"
810
"time"
911

@@ -13,6 +15,27 @@ import (
1315

1416
const ecnMask uint8 = 0x3
1517

18+
func inspectReadBuffer(c net.PacketConn) (int, error) {
19+
conn, ok := c.(interface {
20+
SyscallConn() (syscall.RawConn, error)
21+
})
22+
if !ok {
23+
return 0, errors.New("doesn't have a SyscallConn")
24+
}
25+
rawConn, err := conn.SyscallConn()
26+
if err != nil {
27+
return 0, fmt.Errorf("couldn't get syscall.RawConn: %w", err)
28+
}
29+
var size int
30+
var serr error
31+
if err := rawConn.Control(func(fd uintptr) {
32+
size, serr = syscall.GetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF)
33+
}); err != nil {
34+
return 0, err
35+
}
36+
return size, serr
37+
}
38+
1639
type ecnConn struct {
1740
ECNCapablePacketConn
1841
oobBuffer []byte

conn_windows.go renamed to conn_generic.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build windows
1+
// +build !darwin,!linux
22

33
package quic
44

conn_helper_generic.go renamed to conn_helper_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !darwin,!windows
1+
// +build linux
22

33
package quic
44

conn_notwindows.go

-31
This file was deleted.

0 commit comments

Comments
 (0)