diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-08-28 00:00:45 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-08-28 00:00:45 +0000 |
commit | 5df75d5fa6e9ded2ab19b56473f4baebef48edbd (patch) | |
tree | ac6d532a63a15a0e28c4779c4a4dbfde2673ff91 /pkg/sentry/kernel/pipe/pipe.go | |
parent | b110c6e52b1e9043fed0604a9037156bce6ca746 (diff) | |
parent | 84f04909c2c3a55b209f01315493e6850160d707 (diff) |
Merge release-20200818.0-77-g84f04909c (automated)
Diffstat (limited to 'pkg/sentry/kernel/pipe/pipe.go')
-rw-r--r-- | pkg/sentry/kernel/pipe/pipe.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pkg/sentry/kernel/pipe/pipe.go b/pkg/sentry/kernel/pipe/pipe.go index 297e8f28f..c410c96aa 100644 --- a/pkg/sentry/kernel/pipe/pipe.go +++ b/pkg/sentry/kernel/pipe/pipe.go @@ -200,17 +200,17 @@ type readOps struct { // // Precondition: this pipe must have readers. func (p *Pipe) read(ctx context.Context, ops readOps) (int64, error) { - // Don't block for a zero-length read even if the pipe is empty. - if ops.left() == 0 { - return 0, nil - } - p.mu.Lock() defer p.mu.Unlock() return p.readLocked(ctx, ops) } func (p *Pipe) readLocked(ctx context.Context, ops readOps) (int64, error) { + // Don't block for a zero-length read even if the pipe is empty. + if ops.left() == 0 { + return 0, nil + } + // Is the pipe empty? if p.view.Size() == 0 { if !p.HasWriters() { @@ -388,6 +388,10 @@ func (p *Pipe) rwReadiness() waiter.EventMask { func (p *Pipe) queued() int64 { p.mu.Lock() defer p.mu.Unlock() + return p.queuedLocked() +} + +func (p *Pipe) queuedLocked() int64 { return p.view.Size() } |