diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-09 19:54:00 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-09 19:54:00 +0100 |
commit | a97ef39cd4a8a7612ff744ff0e7a4efdf3837214 (patch) | |
tree | 144978993cec083a1ea6ebf87a82c7c4e717dc14 /rwcancel | |
parent | c040dea7985b7b5a35ca2fa746c3385732c44bd1 (diff) |
rwcancel: use errors.Is for unwrapping
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'rwcancel')
-rw-r--r-- | rwcancel/rwcancel.go | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/rwcancel/rwcancel.go b/rwcancel/rwcancel.go index 7d50f83..8a6300a 100644 --- a/rwcancel/rwcancel.go +++ b/rwcancel/rwcancel.go @@ -46,17 +46,7 @@ func NewRWCancel(fd int) (*RWCancel, error) { } func RetryAfterError(err error) bool { - if pe, ok := err.(*os.PathError); ok { - err = pe.Err - } - if errno, ok := err.(syscall.Errno); ok { - switch errno { - case syscall.EAGAIN, syscall.EINTR: - return true - } - - } - return false + return errors.Is(err, syscall.EAGAIN) || errors.Is(err, syscall.EINTR) } func (rw *RWCancel) ReadyRead() bool { |