Skip to content

Commit

Permalink
simplify close condition check
Browse files Browse the repository at this point in the history
  • Loading branch information
WeidiDeng committed Oct 30, 2024
1 parent c422a1b commit 1025d32
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions layer4/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,8 @@ func (l *listener) Close() error {
func (l *listener) loop() {
for {
conn, err := l.Listener.Accept()
// listener closed
if l.closed.Load() {
break
}

var nerr net.Error
if errors.As(err, &nerr) && nerr.Temporary() {
if errors.As(err, &nerr) && nerr.Temporary() && !l.closed.Load() {
l.logger.Error("temporary error accepting connection", zap.Error(err))
continue
}
Expand Down

0 comments on commit 1025d32

Please sign in to comment.