Skip to content

Commit 1b93f82

Browse files
committed
nilaway,lint: core/sockopt.go
1 parent 380a850 commit 1b93f82

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

intra/core/sockopt.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,18 @@ func SetTimeoutSockOpt(c MinConn, timeoutms int) bool {
6565
return false
6666
}
6767

68-
func DisableKeepAlive(c MinConn) bool {
69-
if sc, ok := c.(syscall.Conn); ok {
68+
func DisableKeepAlive(c MinConn) (done bool) {
69+
if sc, ok := c.(PoolableConn); ok {
7070
raw, err := sc.SyscallConn()
71-
if err != nil {
72-
return false
71+
if raw == nil || err != nil {
72+
return
7373
}
7474
err = raw.Control(func(fd uintptr) {
75-
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 0)
75+
err = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 0)
7676
})
77-
if err != nil {
78-
return false
79-
}
80-
return true
77+
return err == nil
8178
}
82-
return false
79+
return
8380
}
8481

8582
// SetKeepAliveConfigSockOpt sets for a TCP connection, SO_KEEPALIVE,

0 commit comments

Comments
 (0)