mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02: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.
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
|
* Copyright (c) 2023, Lucas Chollet <lucas.chollet@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <ImageDecoder/ConnectionFromClient.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
#include <LibCore/EventLoop.h>
|
|
#include <LibCore/Process.h>
|
|
#include <LibIPC/SingleServer.h>
|
|
#include <LibMain/Main.h>
|
|
|
|
ErrorOr<int> ladybird_main(Main::Arguments arguments)
|
|
{
|
|
AK::set_rich_debug_enabled(true);
|
|
|
|
Core::ArgsParser args_parser;
|
|
StringView mach_server_name;
|
|
bool wait_for_debugger = false;
|
|
|
|
args_parser.add_option(mach_server_name, "Mach server name", "mach-server-name", 0, "mach_server_name");
|
|
args_parser.add_option(wait_for_debugger, "Wait for debugger", "wait-for-debugger");
|
|
args_parser.parse(arguments);
|
|
|
|
if (wait_for_debugger)
|
|
Core::Process::wait_for_debugger_and_break();
|
|
|
|
Core::EventLoop event_loop;
|
|
|
|
auto client = TRY(IPC::take_over_accepted_client_from_system_server<ImageDecoder::ConnectionFromClient>(mach_server_name));
|
|
|
|
return event_loop.exec();
|
|
}
|