Fix "use of closed network connection" error check

This was refactored out incorrectly in a previous change.
This commit is contained in:
Erik Dubbelboer
2022-08-26 14:15:21 +02:00
parent 3b147b7fe4
commit 28bec71c96
+11 -11
View File
@@ -1861,21 +1861,21 @@ func acceptConn(s *Server, ln net.Listener, lastPerIPErrorTime *time.Time) (net.
var c net.Conn
var err error
if tl, ok := ln.(*net.TCPListener); ok && s.TCPKeepalive {
tc, err := tl.AcceptTCP()
if err != nil {
return nil, err
}
if err := tc.SetKeepAlive(s.TCPKeepalive); err != nil {
tc.Close() //nolint:errcheck
return nil, err
}
if s.TCPKeepalivePeriod > 0 {
if err := tc.SetKeepAlivePeriod(s.TCPKeepalivePeriod); err != nil {
var tc *net.TCPConn
tc, err = tl.AcceptTCP()
if err == nil {
if err := tc.SetKeepAlive(s.TCPKeepalive); err != nil {
tc.Close() //nolint:errcheck
return nil, err
}
if s.TCPKeepalivePeriod > 0 {
if err := tc.SetKeepAlivePeriod(s.TCPKeepalivePeriod); err != nil {
tc.Close() //nolint:errcheck
return nil, err
}
}
c = tc
}
c = tc
} else {
c, err = ln.Accept()
}