Skip to content

Commit

Permalink
timeout checks are hard
Browse files Browse the repository at this point in the history
  • Loading branch information
aldas committed Jul 27, 2023
1 parent f3b89db commit b9c1f75
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"io"
"log"
"net"
"strings"
"os"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -215,14 +215,6 @@ func (s *Server) trackConn(c *connection, isAdd bool) {
}
}

func isTimeout(err error) bool {
var terr interface{ Timeout() bool }
if errors.As(err, &terr) && terr.Timeout() {
return true
}
return strings.Contains(err.Error(), "i/o timeout")
}

func (c *connection) handle(ctx context.Context) {
cCtx, cCancel := context.WithCancel(ctx)
defer cCancel()
Expand Down Expand Up @@ -252,7 +244,7 @@ func (c *connection) handle(ctx context.Context) {
if debugRawRead {
rrt.Read(received[0:n], n, err)
}
if err != nil && !isTimeout(err) {
if err != nil && !errors.Is(err, os.ErrDeadlineExceeded) {
if !errors.Is(err, io.EOF) {
c.onErrorFunc(err)
}
Expand Down

0 comments on commit b9c1f75

Please sign in to comment.