File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package netpoll
1616
1717import (
1818 "fmt"
19+ "net"
1920 "syscall"
2021)
2122
@@ -51,6 +52,10 @@ func Exception(err error, suffix string) error {
5152 return & exception {no : no , suffix : suffix }
5253}
5354
55+ var (
56+ _ net.Error = (* exception )(nil )
57+ )
58+
5459type exception struct {
5560 no syscall.Errno
5661 suffix string
@@ -88,6 +93,21 @@ func (e *exception) Unwrap() error {
8893 return e .no
8994}
9095
96+ func (e * exception ) Timeout () bool {
97+ switch e .no {
98+ case ErrDialTimeout , ErrReadTimeout , ErrWriteTimeout :
99+ return true
100+ }
101+ if e .no .Timeout () {
102+ return true
103+ }
104+ return false
105+ }
106+
107+ func (e * exception ) Temporary () bool {
108+ return e .no .Temporary ()
109+ }
110+
91111// Errors defined in netpoll
92112var errnos = [... ]string {
93113 ErrnoMask & ErrConnClosed : "connection has been closed" ,
You can’t perform that action at this time.
0 commit comments