mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 09:50:27 +00:00
On macOS, use Mach port messaging instead of Unix domain sockets for all IPC transport. This makes the transport capable of carrying Mach port rights as message attachments, which is a prerequisite for sending IOSurface handles over the main IPC channel (currently sent via a separate out-of-band path). It also avoids the need for the FD acknowledgement protocol that TransportSocket requires, since Mach port right transfers are atomic in the kernel. Three connection establishment patterns: - Spawned helper processes (WebContent, RequestServer, etc.) use the existing MachPortServer: the child sends its task port with a reply port, and the parent responds with a pre-created port pair. - Socket-bootstrapped connections (WebDriver, BrowserProcess) exchange Mach port names over the socket, then drop the socket. - Pre-created pairs for IPC tests and in-message transport transfer. Attachment on macOS now wraps a MachPort instead of a file descriptor, converting between the two via fileport_makeport()/fileport_makefd(). The LibIPC socket transport tests are disabled on macOS since they are socket-specific.
45 lines
780 B
C++
45 lines
780 B
C++
/*
|
|
* Copyright (c) 2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibCore/System.h>
|
|
#include <LibIPC/Attachment.h>
|
|
|
|
namespace IPC {
|
|
|
|
Attachment::Attachment(Attachment&& other)
|
|
: m_fd(exchange(other.m_fd, -1))
|
|
{
|
|
}
|
|
|
|
Attachment& Attachment::operator=(Attachment&& other)
|
|
{
|
|
if (this != &other) {
|
|
if (m_fd != -1)
|
|
(void)Core::System::close(m_fd);
|
|
m_fd = exchange(other.m_fd, -1);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
Attachment::~Attachment()
|
|
{
|
|
if (m_fd != -1)
|
|
(void)Core::System::close(m_fd);
|
|
}
|
|
|
|
Attachment Attachment::from_fd(int fd)
|
|
{
|
|
Attachment attachment;
|
|
attachment.m_fd = fd;
|
|
return attachment;
|
|
}
|
|
|
|
int Attachment::to_fd()
|
|
{
|
|
return exchange(m_fd, -1);
|
|
}
|
|
|
|
}
|