Skip to content

Commit dffca1f

Browse files
Lanius-collarisignoramous
authored andcommitted
intra/core: fix DisableKeepAlive
1 parent 6f8b77f commit dffca1f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

intra/core/sockopt.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,17 @@ func SetTimeoutSockOpt(c MinConn, timeoutms int) bool {
6666
}
6767

6868
func DisableKeepAlive(c MinConn) bool {
69-
if tc, ok := c.(*net.TCPConn); ok {
70-
tc.SetKeepAlive(false)
69+
if sc, ok := c.(syscall.Conn); ok {
70+
raw, err := sc.SyscallConn()
71+
if err != nil {
72+
return false
73+
}
74+
err = raw.Control(func(fd uintptr) {
75+
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 0)
76+
})
77+
if err != nil {
78+
return false
79+
}
7180
return true
7281
}
7382
return false

0 commit comments

Comments
 (0)