rwcancel: use errors.Is for unwrapping
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
c040dea798
commit
a97ef39cd4
|
@ -46,17 +46,7 @@ func NewRWCancel(fd int) (*RWCancel, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func RetryAfterError(err error) bool {
|
func RetryAfterError(err error) bool {
|
||||||
if pe, ok := err.(*os.PathError); ok {
|
return errors.Is(err, syscall.EAGAIN) || errors.Is(err, syscall.EINTR)
|
||||||
err = pe.Err
|
|
||||||
}
|
|
||||||
if errno, ok := err.(syscall.Errno); ok {
|
|
||||||
switch errno {
|
|
||||||
case syscall.EAGAIN, syscall.EINTR:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rw *RWCancel) ReadyRead() bool {
|
func (rw *RWCancel) ReadyRead() bool {
|
||||||
|
|
Loading…
Reference in a new issue