LibCore+LibIPC: Move SystemServerTakeover.{h,cpp} to LibCore
This functionality is required by Core::LocalServer and LibIPC depends on LibCore. take_over_accepted_socket_from_system_server has also been renamed to take_over_socket_from_system_server as the socket need not be accepted before taking it over. :^)
This commit is contained in:
parent
032ffbcf64
commit
89d9a1afc0
Notes:
sideshowbarker
2024-07-17 19:44:29 +09:00
Author: https://github.com/sin-ack Commit: https://github.com/SerenityOS/serenity/commit/89d9a1afc05 Pull-request: https://github.com/SerenityOS/serenity/pull/11910
6 changed files with 24 additions and 17 deletions
|
@ -32,6 +32,7 @@ set(SOURCES
|
|||
Stream.cpp
|
||||
StandardPaths.cpp
|
||||
System.cpp
|
||||
SystemServerTakeover.cpp
|
||||
TCPServer.cpp
|
||||
TCPSocket.cpp
|
||||
TempFile.cpp
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
#include "SystemServerTakeover.h"
|
||||
#include <LibCore/System.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
HashMap<String, int> s_overtaken_sockets {};
|
||||
bool s_overtaken_sockets_parsed { false };
|
||||
|
||||
void parse_sockets_from_system_server()
|
||||
static void parse_sockets_from_system_server()
|
||||
{
|
||||
VERIFY(!s_overtaken_sockets_parsed);
|
||||
|
||||
|
@ -32,7 +34,7 @@ void parse_sockets_from_system_server()
|
|||
unsetenv(socket_takeover);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_accepted_socket_from_system_server(String const& socket_path)
|
||||
ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_socket_from_system_server(String const& socket_path)
|
||||
{
|
||||
if (!s_overtaken_sockets_parsed)
|
||||
parse_sockets_from_system_server();
|
||||
|
@ -63,3 +65,5 @@ ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_accepted_socket_from
|
|||
|
||||
return socket;
|
||||
}
|
||||
|
||||
}
|
15
Userland/Libraries/LibCore/SystemServerTakeover.h
Normal file
15
Userland/Libraries/LibCore/SystemServerTakeover.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2022, sin-ack <sin-ack@protonmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_socket_from_system_server(String const& socket_path = {});
|
||||
|
||||
}
|
|
@ -4,7 +4,6 @@ set(SOURCES
|
|||
Encoder.cpp
|
||||
Message.cpp
|
||||
Stub.cpp
|
||||
SystemServerTakeover.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibIPC ipc)
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCore/SystemServerTakeover.h>
|
||||
#include <LibIPC/ClientConnection.h>
|
||||
#include <LibIPC/SystemServerTakeover.h>
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<typename ClientConnectionType>
|
||||
ErrorOr<NonnullRefPtr<ClientConnectionType>> take_over_accepted_client_from_system_server()
|
||||
{
|
||||
auto socket = TRY(take_over_accepted_socket_from_system_server());
|
||||
auto socket = TRY(Core::take_over_socket_from_system_server());
|
||||
return IPC::new_client_connection<ClientConnectionType>(move(socket));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, sin-ack <sin-ack@protonmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
void parse_sockets_from_system_server();
|
||||
ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_accepted_socket_from_system_server(String const& socket_path = {});
|
Loading…
Add table
Reference in a new issue