1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:57:46 +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

@ -77,8 +77,8 @@ ClientConnection* ClientConnection::from_client_id(int client_id)
return (*it).value.ptr();
}
ClientConnection::ClientConnection(Core::LocalSocket& client_socket, int client_id)
: IPC::ClientConnection<WindowServerEndpoint>(*this, client_socket, client_id)
ClientConnection::ClientConnection(NonnullRefPtr<Core::LocalSocket> client_socket, int client_id)
: IPC::ClientConnection<WindowServerEndpoint>(*this, move(client_socket), client_id)
{
if (!s_connections)
s_connections = new HashMap<int, NonnullRefPtr<ClientConnection>>;

View file

@ -84,7 +84,7 @@ public:
void notify_display_link(Badge<Compositor>);
private:
explicit ClientConnection(Core::LocalSocket&, int client_id);
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);
// ^ClientConnection
virtual void die() override;

View file

@ -63,7 +63,7 @@ EventLoop::EventLoop()
}
static int s_next_client_id = 0;
int client_id = ++s_next_client_id;
IPC::new_client_connection<ClientConnection>(*client_socket, client_id);
IPC::new_client_connection<ClientConnection>(client_socket.release_nonnull(), client_id);
};
ASSERT(m_keyboard_fd >= 0);