Skip to content

Commit

Permalink
Fix "use of closed network connection" error check
Browse files Browse the repository at this point in the history
This was refactored out incorrectly in a previous change.
  • Loading branch information
erikdubbelboer committed Aug 26, 2022
1 parent 3b147b7 commit 28bec71
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 28bec71

Please sign in to comment.