rwcancel: use errors.Is for unwrapping

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-02-09 19:54:00 +01:00
parent c040dea798
commit a97ef39cd4

View file

@ -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 {