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.
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/NonnullOwnPtr.h>
|
|
#include <AK/Platform.h>
|
|
#include <LibIPC/File.h>
|
|
#include <LibIPC/Forward.h>
|
|
|
|
#if defined(AK_OS_MACOS)
|
|
# include <LibCore/MachPort.h>
|
|
#endif
|
|
|
|
namespace IPC {
|
|
|
|
class TransportHandle {
|
|
AK_MAKE_NONCOPYABLE(TransportHandle);
|
|
|
|
public:
|
|
TransportHandle() = default;
|
|
TransportHandle(TransportHandle&&) = default;
|
|
TransportHandle& operator=(TransportHandle&&) = default;
|
|
|
|
#if defined(AK_OS_MACOS)
|
|
TransportHandle(Core::MachPort receive_right, Core::MachPort send_right);
|
|
#else
|
|
explicit TransportHandle(File);
|
|
#endif
|
|
|
|
ErrorOr<NonnullOwnPtr<Transport>> create_transport() const;
|
|
|
|
private:
|
|
#if defined(AK_OS_MACOS)
|
|
mutable Core::MachPort m_receive_right;
|
|
mutable Core::MachPort m_send_right;
|
|
#else
|
|
mutable File m_file;
|
|
#endif
|
|
|
|
template<typename U>
|
|
friend ErrorOr<void> encode(Encoder&, U const&);
|
|
|
|
template<typename U>
|
|
friend ErrorOr<U> decode(Decoder&);
|
|
};
|
|
|
|
}
|