From 644e764620979a90483b7bc430ea76288b4b08f2 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 12 Mar 2024 15:02:54 -0400 Subject: [PATCH] RequestServer: Use Core::System::pipe2 for creating the request FDs This causes a behavior change in which the read FD is now non-blocking. This is intentional, as this change avoids a deadlock between RS and WebContent, where WC could block while reading from the request FD, while RS is blocked sending a message to WC. --- Userland/Services/RequestServer/Protocol.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Userland/Services/RequestServer/Protocol.cpp b/Userland/Services/RequestServer/Protocol.cpp index 552ae2bef4..1dce3e9539 100644 --- a/Userland/Services/RequestServer/Protocol.cpp +++ b/Userland/Services/RequestServer/Protocol.cpp @@ -6,11 +6,8 @@ #include #include +#include #include -#include -#include -#include -#include namespace RequestServer { @@ -32,13 +29,7 @@ Protocol::Protocol(ByteString const& name) ErrorOr Protocol::get_pipe_for_request() { - int fd_pair[2] { 0 }; - if (pipe(fd_pair) != 0) { - auto saved_errno = errno; - dbgln("Protocol: pipe() failed: {}", strerror(saved_errno)); - return Error::from_errno(saved_errno); - } - fcntl(fd_pair[1], F_SETFL, fcntl(fd_pair[1], F_GETFL) | O_NONBLOCK); + auto fd_pair = TRY(Core::System::pipe2(O_NONBLOCK)); return Pipe { fd_pair[0], fd_pair[1] }; }