1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:47:45 +00:00

LibIPC+Services: Make ClientConnection take socket as NonnullRefPtr

This avoids getting into the awkward situation where the socket is
still part-owned by main() in multi-instance service. Also it just
reads nicer.
This commit is contained in:
Andreas Kling 2020-07-06 13:23:39 +02:00
parent f9d3055691
commit 94ddb07e58
25 changed files with 40 additions and 40 deletions

View file

@ -9,4 +9,4 @@ set(SOURCES
)
serenity_bin(ImageDecoder)
target_link_libraries(ImageDecoder LibIPC LibGfx)
target_link_libraries(ImageDecoder LibGfx LibIPC)

View file

@ -36,8 +36,8 @@ namespace ImageDecoder {
static HashMap<int, RefPtr<ClientConnection>> s_connections;
ClientConnection::ClientConnection(Core::LocalSocket& socket, int client_id)
: IPC::ClientConnection<ImageDecoderServerEndpoint>(*this, socket, client_id)
ClientConnection::ClientConnection(NonnullRefPtr<Core::LocalSocket> socket, int client_id)
: IPC::ClientConnection<ImageDecoderServerEndpoint>(*this, move(socket), client_id)
{
s_connections.set(client_id, *this);
}

View file

@ -40,7 +40,7 @@ class ClientConnection final
C_OBJECT(ClientConnection);
public:
explicit ClientConnection(Core::LocalSocket&, int client_id);
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);
~ClientConnection() override;
virtual void die() override;

View file

@ -42,7 +42,7 @@ int main(int, char**)
}
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
IPC::new_client_connection<ImageDecoder::ClientConnection>(*socket, 1);
IPC::new_client_connection<ImageDecoder::ClientConnection>(socket.release_nonnull(), 1);
if (pledge("stdio shared_buffer", nullptr) < 0) {
perror("pledge");
return 1;