mirror of
https://github.com/caddyserver/caddy.git
synced 2025-04-23 13:14:08 +08:00
httpserver: no SetKeepAlivePeriod in openbsd (#2787)
* no SetKeepAlivePeriod on openbsd * fix tcpKeepAliveListener.Accept signature
This commit is contained in:
parent
16b296c97e
commit
be2fdb6af6
@ -554,16 +554,20 @@ type tcpKeepAliveListener struct {
|
||||
}
|
||||
|
||||
// Accept accepts the connection with a keep-alive enabled.
|
||||
func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) {
|
||||
func (ln tcpKeepAliveListener) Accept() (net.Conn, error) {
|
||||
tc, err := ln.AcceptTCP()
|
||||
if err != nil {
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
if err = tc.SetKeepAlive(true); err != nil {
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
if err = tc.SetKeepAlivePeriod(3 * time.Minute); err != nil {
|
||||
return
|
||||
// OpenBSD has no user-settable per-socket TCP keepalive
|
||||
// https://github.com/caddyserver/caddy/pull/2787
|
||||
if runtime.GOOS != "openbsd" {
|
||||
if err = tc.SetKeepAlivePeriod(3 * time.Minute); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return tc, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user