diff options
author | Andrei Vagin <avagin@google.com> | 2019-05-23 23:20:11 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-05-23 23:21:13 -0700 |
commit | a949133c4b22a87c79310b2d825f2899028d6088 (patch) | |
tree | 439e03ccfff0c8bfe64cdef3e5191d39015b957c /pkg/sentry/fs/file.go | |
parent | 409e8eea60f096b34c9005b302dc821f38ac19ed (diff) |
gvisor: interrupt the sendfile system call if a task has been interrupted
sendfile can be called for a big range and it can require significant
amount of time to process it, so we need to handle task interrupts in
this system call.
PiperOrigin-RevId: 249781023
Change-Id: Ifc2ec505d74c06f5ee76f93b8d30d518ec2d4015
Diffstat (limited to 'pkg/sentry/fs/file.go')
-rw-r--r-- | pkg/sentry/fs/file.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/sentry/fs/file.go b/pkg/sentry/fs/file.go index 8f1baca23..8c1307235 100644 --- a/pkg/sentry/fs/file.go +++ b/pkg/sentry/fs/file.go @@ -516,12 +516,18 @@ type lockedReader struct { // Read implements io.Reader.Read. func (r *lockedReader) Read(buf []byte) (int, error) { + if r.Ctx.Interrupted() { + return 0, syserror.ErrInterrupted + } n, err := r.File.FileOperations.Read(r.Ctx, r.File, usermem.BytesIOSequence(buf), r.File.offset) return int(n), err } // ReadAt implements io.Reader.ReadAt. func (r *lockedReader) ReadAt(buf []byte, offset int64) (int, error) { + if r.Ctx.Interrupted() { + return 0, syserror.ErrInterrupted + } n, err := r.File.FileOperations.Read(r.Ctx, r.File, usermem.BytesIOSequence(buf), offset) return int(n), err } |