From b701ee221434572881b9b3b0164d5a5b54714fa9 Mon Sep 17 00:00:00 2001 From: Ian Gudger Date: Tue, 1 May 2018 08:06:11 -0700 Subject: Fix SO_RCVTIMEOUT for recvmsg PiperOrigin-RevId: 194938091 Change-Id: Id17f26df13a915ec0c388aad3198207ea1c28d53 --- pkg/sentry/syscalls/linux/sys_socket.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/sentry/syscalls/linux/sys_socket.go b/pkg/sentry/syscalls/linux/sys_socket.go index 3797c0a5d..70c618398 100644 --- a/pkg/sentry/syscalls/linux/sys_socket.go +++ b/pkg/sentry/syscalls/linux/sys_socket.go @@ -610,7 +610,14 @@ func RecvMsg(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysca flags |= linux.MSG_DONTWAIT } - n, err := recvSingleMsg(t, s, msgPtr, flags, false, ktime.Time{}) + var haveDeadline bool + var deadline ktime.Time + if dl := s.RecvTimeout(); dl != 0 { + deadline = t.Kernel().MonotonicClock().Now().Add(time.Duration(dl) * time.Nanosecond) + haveDeadline = true + } + + n, err := recvSingleMsg(t, s, msgPtr, flags, haveDeadline, deadline) return n, nil, err } -- cgit v1.2.3