mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 03:24:58 +00:00
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.
This commit is contained in:
parent
a973fe13cb
commit
644e764620
1 changed files with 2 additions and 11 deletions
|
@ -6,11 +6,8 @@
|
|||
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <RequestServer/Protocol.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace RequestServer {
|
||||
|
||||
|
@ -32,13 +29,7 @@ Protocol::Protocol(ByteString const& name)
|
|||
|
||||
ErrorOr<Protocol::Pipe> 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] };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue