summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket/unix
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-12-13 13:19:39 -0800
committerShentubot <shentubot@google.com>2018-12-13 13:20:46 -0800
commit4659f7ed1a63f031b5450d065684ef6c32d35f01 (patch)
treecfb15ddd2e80b2a497e3160352155fa6a2060c0f /pkg/sentry/socket/unix
parent6253d32cc932e76608be5c57a4870b3d61464487 (diff)
Fix WAITALL and RCVTIMEO interaction
PiperOrigin-RevId: 225424296 Change-Id: I60fcc2b859339dca9963cb32227a287e719ab765
Diffstat (limited to 'pkg/sentry/socket/unix')
-rw-r--r--pkg/sentry/socket/unix/unix.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/pkg/sentry/socket/unix/unix.go b/pkg/sentry/socket/unix/unix.go
index 11cad411d..4c9dcbd61 100644
--- a/pkg/sentry/socket/unix/unix.go
+++ b/pkg/sentry/socket/unix/unix.go
@@ -538,6 +538,9 @@ func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
}
total += n
if err != nil || !waitAll || s.isPacket || n >= dst.NumBytes() {
+ if total > 0 {
+ err = nil
+ }
return int(total), from, fromLen, socket.ControlMessages{Unix: r.Control}, syserr.FromError(err)
}
@@ -546,10 +549,13 @@ func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
}
if err := t.BlockWithDeadline(ch, haveDeadline, deadline); err != nil {
+ if total > 0 {
+ err = nil
+ }
if err == syserror.ETIMEDOUT {
- return 0, nil, 0, socket.ControlMessages{}, syserr.ErrTryAgain
+ return int(total), nil, 0, socket.ControlMessages{}, syserr.ErrTryAgain
}
- return 0, nil, 0, socket.ControlMessages{}, syserr.FromError(err)
+ return int(total), nil, 0, socket.ControlMessages{}, syserr.FromError(err)
}
}
}