Skip to content

Commit c7c8597

Browse files
committed
Fix crash on OpenBSD due to unsupported TCP KeepAlivePeriod
1 parent 5c7c87d commit c7c8597

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
@@ -826,9 +826,10 @@ func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) {
826826
return
827827
} else if err = c.(*net.TCPConn).SetKeepAlive(true); err != nil {
828828
return
829-
} else if err = c.(*net.TCPConn).SetKeepAlivePeriod(3 * time.Minute); err != nil {
830-
return
831829
}
830+
// Ignore error from setting the KeepAlivePeriod as some systems, such as
831+
// OpenBSD, do not support setting TCP_USER_TIMEOUT on IPPROTO_TCP
832+
_ = c.(*net.TCPConn).SetKeepAlivePeriod(3 * time.Minute)
832833
return
833834
}
834835

0 commit comments

Comments
 (0)