private/server: tcp_fastopen failures should not kill the server

Change-Id: Iec42524f83619c22d8be26f373978e8abd468ee8
This commit is contained in:
JT Olio 2023-01-31 09:00:44 -05:00 committed by Egon Elbre
parent 053beef8c4
commit c17ceef093
2 changed files with 11 additions and 5 deletions

View File

@ -15,4 +15,9 @@ func setTCPFastOpen(fd uintptr, queue int) error {
return syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_TCP, tcpFastOpenServer, 1)
}
func tryInitFastOpen(*zap.Logger) {}
func tryInitFastOpen(*zap.Logger) {
// should we log or check something along the lines of
// netsh int tcp set global fastopen=enabled
// netsh int tcp set global fastopenfallback=disabled
// ?
}

View File

@ -130,11 +130,12 @@ func New(log *zap.Logger, tlsOptions *tlsopts.Options, config Config) (_ *Server
if config.TCPFastOpen {
tryInitFastOpen(log)
listenConfig.Control = func(network, address string, c syscall.RawConn) error {
var internalErr error
err := c.Control(func(fd uintptr) {
internalErr = setTCPFastOpen(fd, config.TCPFastOpenQueue)
return c.Control(func(fd uintptr) {
err := setTCPFastOpen(fd, config.TCPFastOpenQueue)
if err != nil {
log.Sugar().Infof("failed to set tcp fast open for this socket: %v", err)
}
})
return errs.Combine(err, internalErr)
}
}