From 912cae21b070e6f5972ce34a08b25e4ae2182d5c Mon Sep 17 00:00:00 2001 From: Link4565 <49906383+Link4565@users.noreply.github.com> Date: Tue, 28 Jun 2022 20:29:41 +0100 Subject: Enable the use of MSG_DONTWAIT flag on RecvImpl --- src/core/hle/service/sockets/bsd.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index 5114b8be2..3e9dc4a13 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -720,7 +720,25 @@ std::pair BSD::RecvImpl(s32 fd, u32 flags, std::vector& message) if (!IsFileDescriptorValid(fd)) { return {-1, Errno::BADF}; } - return Translate(file_descriptors[fd]->socket->Recv(flags, message)); + + FileDescriptor& descriptor = *file_descriptors[fd]; + + // Apply flags + if ((flags & FLAG_MSG_DONTWAIT) != 0) { + flags &= ~FLAG_MSG_DONTWAIT; + if ((descriptor.flags & FLAG_O_NONBLOCK) == 0) { + descriptor.socket->SetNonBlock(true); + } + } + + const auto [ret, bsd_errno] = Translate(descriptor.socket->Recv(flags, message)); + + // Restore original state + if ((descriptor.flags & FLAG_O_NONBLOCK) == 0) { + descriptor.socket->SetNonBlock(false); + } + + return {ret, bsd_errno}; } std::pair BSD::RecvFromImpl(s32 fd, u32 flags, std::vector& message, -- cgit v1.2.3