diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-08-14 00:21:23 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-08-14 00:21:23 +0000 |
commit | 3b15f3497631993c9a2aca40abd691993c0acb79 (patch) | |
tree | fd4e3a66fa5471772934b2f923c0511656b011eb /pkg/syserr/syserr.go | |
parent | 04387bed63970c84d62156a9c1b3c6112b9aca21 (diff) | |
parent | ce58d71fd526587c0ed5e898e3a680c30c02c6d2 (diff) |
Merge release-20210806.0-29-gce58d71fd (automated)
Diffstat (limited to 'pkg/syserr/syserr.go')
-rw-r--r-- | pkg/syserr/syserr.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pkg/syserr/syserr.go b/pkg/syserr/syserr.go index 558240008..a5e386e38 100644 --- a/pkg/syserr/syserr.go +++ b/pkg/syserr/syserr.go @@ -24,7 +24,6 @@ import ( "gvisor.dev/gvisor/pkg/abi/linux/errno" "gvisor.dev/gvisor/pkg/errors" "gvisor.dev/gvisor/pkg/errors/linuxerr" - "gvisor.dev/gvisor/pkg/syserror" ) // Error represents an internal error. @@ -52,12 +51,12 @@ func New(message string, linuxTranslation errno.Errno) *Error { } e := error(unix.Errno(err.errno)) - // syserror.ErrWouldBlock gets translated to linuxerr.EWOULDBLOCK and + // linuxerr.ErrWouldBlock gets translated to linuxerr.EWOULDBLOCK and // enables proper blocking semantics. This should temporary address the // class of blocking bugs that keep popping up with the current state of // the error space. if err.errno == linuxerr.EWOULDBLOCK.Errno() { - e = syserror.ErrWouldBlock + e = linuxerr.ErrWouldBlock } linuxBackwardsTranslations[err.errno] = linuxBackwardsTranslation{err: e, ok: true} @@ -287,8 +286,14 @@ func FromError(err error) *Error { return FromHost(unix.Errno(linuxErr.Errno())) } - if errno, ok := syserror.TranslateError(err); ok { - return FromHost(errno) - } panic("unknown error: " + err.Error()) } + +// ConvertIntr converts the provided error code (err) to another one (intr) if +// the first error corresponds to an interrupted operation. +func ConvertIntr(err, intr error) error { + if err == linuxerr.ErrInterrupted { + return intr + } + return err +} |