Skip to content

Commit

Permalink
Merge pull request #338 from lesismal/accept_err
Browse files Browse the repository at this point in the history
fix accept error handling
  • Loading branch information
lesismal authored Aug 5, 2023
2 parents 1a9db94 + 5ec91f3 commit 204def4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lmux/lmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (lm *ListenerMux) Start() {
c, err := l.Accept()
if err != nil {
var ne net.Error
if ok := errors.As(err, &ne); ok && ne.Timeout() {
if ok := errors.As(err, &ne); ok && ne.Temporary() {
logging.Error("Accept failed: temporary error, retrying...")
time.Sleep(time.Second / 20)
continue
Expand Down
2 changes: 1 addition & 1 deletion nbhttp/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func (e *Engine) listen(ln net.Listener, tlsConfig *tls.Config, addConn func(net
addConn(conn, tlsConfig, decrease)
} else {
var ne net.Error
if ok := errors.As(err, &ne); ok && ne.Timeout() {
if ok := errors.As(err, &ne); ok && ne.Temporary() {
logging.Error("Accept failed: temporary error, retrying...")
time.Sleep(time.Second / 20)
} else {
Expand Down
2 changes: 1 addition & 1 deletion poller_epoll.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (p *poller) acceptorLoop() {
p.g.pollers[c.Hash()%len(p.g.pollers)].addConn(c)
} else {
var ne net.Error
if ok := errors.As(err, &ne); ok && ne.Timeout() {
if ok := errors.As(err, &ne); ok && ne.Temporary() {
logging.Error("NBIO[%v][%v_%v] Accept failed: temporary error, retrying...", p.g.Name, p.pollType, p.index)
time.Sleep(time.Second / 20)
} else {
Expand Down
2 changes: 1 addition & 1 deletion poller_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (p *poller) start() {
for !p.shutdown {
err = p.accept()
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Timeout() {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
logging.Error("NBIO[%v][%v_%v] Accept failed: temporary error, retrying...", p.g.Name, p.pollType, p.index)
time.Sleep(time.Second / 20)
} else {
Expand Down

0 comments on commit 204def4

Please sign in to comment.