Skip to content

Commit fa87a5e

Browse files
committed
Fix crash on OpenBSD due to unsupported TCP KeepAlivePeriod
1 parent 75620e6 commit fa87a5e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

echo.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,10 @@ func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) {
856856
return
857857
} else if err = c.(*net.TCPConn).SetKeepAlive(true); err != nil {
858858
return
859-
} else if err = c.(*net.TCPConn).SetKeepAlivePeriod(3 * time.Minute); err != nil {
860-
return
861859
}
860+
// Ignore error from setting the KeepAlivePeriod as some systems, such as
861+
// OpenBSD, do not support setting TCP_USER_TIMEOUT on IPPROTO_TCP
862+
_ = c.(*net.TCPConn).SetKeepAlivePeriod(3 * time.Minute)
862863
return
863864
}
864865

0 commit comments

Comments
 (0)