Ignore errors when setting keepalive period is not supported by the system

This commit is contained in:
Tristan Weil 2020-10-28 15:32:04 +01:00 committed by GitHub
parent a0c02f62a3
commit db007efe00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,11 +2,13 @@ package server
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
stdlog "log" stdlog "log"
"net" "net"
"net/http" "net/http"
"sync" "sync"
"syscall"
"time" "time"
proxyprotocol "github.com/c0va23/go-proxyprotocol" proxyprotocol "github.com/c0va23/go-proxyprotocol"
@ -340,7 +342,11 @@ func (ln tcpKeepAliveListener) Accept() (net.Conn, error) {
} }
if err = tc.SetKeepAlivePeriod(3 * time.Minute); err != nil { if err = tc.SetKeepAlivePeriod(3 * time.Minute); err != nil {
return nil, err // Some systems, such as OpenBSD, have no user-settable per-socket TCP
// keepalive options.
if !errors.Is(err, syscall.ENOPROTOOPT) {
return nil, err
}
} }
return tc, nil return tc, nil