Skip to content

Commit c5078bd

Browse files
authored
fix: make timeout error implement net.Error (#283)
1 parent 3c57951 commit c5078bd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sess.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,17 @@ const (
8282

8383
var (
8484
errInvalidOperation = errors.New("invalid operation")
85-
errTimeout = errors.New("timeout")
85+
errTimeout = timeoutError{}
8686
errNotOwner = errors.New("not the owner of this connection")
8787
)
8888

89+
// timeoutError implements net.Error
90+
type timeoutError struct{}
91+
92+
func (timeoutError) Error() string { return "timeout" }
93+
func (timeoutError) Timeout() bool { return true }
94+
func (timeoutError) Temporary() bool { return true }
95+
8996
var (
9097
// a system-wide packet buffer shared among sending, receiving and FEC
9198
// to mitigate high-frequency memory allocation for packets, bytes from xmitBuf

0 commit comments

Comments
 (0)