mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
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
6 changed files with 24 additions and 17 deletions
|
@ -32,6 +32,7 @@ set(SOURCES
|
||||||
Stream.cpp
|
Stream.cpp
|
||||||
StandardPaths.cpp
|
StandardPaths.cpp
|
||||||
System.cpp
|
System.cpp
|
||||||
|
SystemServerTakeover.cpp
|
||||||
TCPServer.cpp
|
TCPServer.cpp
|
||||||
TCPSocket.cpp
|
TCPSocket.cpp
|
||||||
TempFile.cpp
|
TempFile.cpp
|
||||||
|
|
|
@ -7,10 +7,12 @@
|
||||||
#include "SystemServerTakeover.h"
|
#include "SystemServerTakeover.h"
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
|
||||||
HashMap<String, int> s_overtaken_sockets {};
|
HashMap<String, int> s_overtaken_sockets {};
|
||||||
bool s_overtaken_sockets_parsed { false };
|
bool s_overtaken_sockets_parsed { false };
|
||||||
|
|
||||||
void parse_sockets_from_system_server()
|
static void parse_sockets_from_system_server()
|
||||||
{
|
{
|
||||||
VERIFY(!s_overtaken_sockets_parsed);
|
VERIFY(!s_overtaken_sockets_parsed);
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ void parse_sockets_from_system_server()
|
||||||
unsetenv(socket_takeover);
|
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)
|
if (!s_overtaken_sockets_parsed)
|
||||||
parse_sockets_from_system_server();
|
parse_sockets_from_system_server();
|
||||||
|
@ -63,3 +65,5 @@ ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_accepted_socket_from
|
||||||
|
|
||||||
return socket;
|
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
|
Encoder.cpp
|
||||||
Message.cpp
|
Message.cpp
|
||||||
Stub.cpp
|
Stub.cpp
|
||||||
SystemServerTakeover.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_lib(LibIPC ipc)
|
serenity_lib(LibIPC ipc)
|
||||||
|
|
|
@ -7,15 +7,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
|
#include <LibCore/SystemServerTakeover.h>
|
||||||
#include <LibIPC/ClientConnection.h>
|
#include <LibIPC/ClientConnection.h>
|
||||||
#include <LibIPC/SystemServerTakeover.h>
|
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
template<typename ClientConnectionType>
|
template<typename ClientConnectionType>
|
||||||
ErrorOr<NonnullRefPtr<ClientConnectionType>> take_over_accepted_client_from_system_server()
|
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));
|
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
Add a link
Reference in a new issue