Skip to content

Commit

Permalink
Improve AcceptTCP error handling: Exclude net.ErrClosed from logging
Browse files Browse the repository at this point in the history
Omit logging of net.ErrClosed errors, as they are expected during normal program termination.
  • Loading branch information
hmgle committed Mar 27, 2024
1 parent 7d995e2 commit 1969438
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package local

import (
"bufio"
"errors"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -167,7 +168,9 @@ func (l *Local) StartService(ln *net.TCPListener) {
for {
conn, err := ln.AcceptTCP()
if err != nil {
log.Errorf("accept err: %s", err.Error())
if !errors.Is(err, net.ErrClosed) {
log.Errorf("accept err: %s", err.Error())
}
break
}
go l.HandleConn(conn)
Expand Down

0 comments on commit 1969438

Please sign in to comment.