From e7ca2a51a89a8ff2c9f5adfdfa5b51be1b3faeb3 Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Wed, 24 Mar 2021 12:08:24 -0700 Subject: Add POLLRDNORM/POLLWRNORM support. On Linux these are meant to be equivalent to POLLIN/POLLOUT. Rather than hack these on in sys_poll etc it felt cleaner to just cleanup the call sites to notify for both events. This is what linux does as well. Fixes #5544 PiperOrigin-RevId: 364859977 --- pkg/sentry/socket/hostinet/socket.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'pkg/sentry/socket/hostinet/socket.go') diff --git a/pkg/sentry/socket/hostinet/socket.go b/pkg/sentry/socket/hostinet/socket.go index c711d0684..2d9dbbdba 100644 --- a/pkg/sentry/socket/hostinet/socket.go +++ b/pkg/sentry/socket/hostinet/socket.go @@ -200,9 +200,10 @@ func (s *socketOpsCommon) Connect(t *kernel.Task, sockaddr []byte, blocking bool // (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual error // codes listed here, explaining the reason for the failure)." - connect(2) e, ch := waiter.NewChannelEntry(nil) - s.EventRegister(&e, waiter.EventOut) + writableMask := waiter.WritableEvents + s.EventRegister(&e, writableMask) defer s.EventUnregister(&e) - if s.Readiness(waiter.EventOut)&waiter.EventOut == 0 { + if s.Readiness(writableMask)&writableMask == 0 { if err := t.Block(ch); err != nil { return syserr.FromError(err) } @@ -244,7 +245,7 @@ func (s *socketOpsCommon) Accept(t *kernel.Task, peerRequested bool, flags int, } else { var e waiter.Entry e, ch = waiter.NewChannelEntry(nil) - s.EventRegister(&e, waiter.EventIn) + s.EventRegister(&e, waiter.ReadableEvents) defer s.EventUnregister(&e) } fd, syscallErr = accept4(s.fd, peerAddrPtr, peerAddrlenPtr, unix.SOCK_NONBLOCK|unix.SOCK_CLOEXEC) @@ -496,7 +497,7 @@ func (s *socketOpsCommon) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags } else { var e waiter.Entry e, ch = waiter.NewChannelEntry(nil) - s.EventRegister(&e, waiter.EventIn) + s.EventRegister(&e, waiter.ReadableEvents) defer s.EventUnregister(&e) } n, err = copyToDst() @@ -652,7 +653,7 @@ func (s *socketOpsCommon) SendMsg(t *kernel.Task, src usermem.IOSequence, to []b } else { var e waiter.Entry e, ch = waiter.NewChannelEntry(nil) - s.EventRegister(&e, waiter.EventOut) + s.EventRegister(&e, waiter.WritableEvents) defer s.EventUnregister(&e) } n, err = src.CopyInTo(t, sendmsgFromBlocks) -- cgit v1.2.3