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

@ -50,8 +50,8 @@ void ClientConnection::for_each(Function<void(ClientConnection&)> callback)
callback(connection);
}
ClientConnection::ClientConnection(Core::LocalSocket& client_socket, int client_id, Mixer& mixer)
: IPC::ClientConnection<AudioServerEndpoint>(*this, client_socket, client_id)
ClientConnection::ClientConnection(NonnullRefPtr<Core::LocalSocket> client_socket, int client_id, Mixer& mixer)
: IPC::ClientConnection<AudioServerEndpoint>(*this, move(client_socket), client_id)
, m_mixer(mixer)
{
s_connections.set(client_id, *this);

View file

@ -43,7 +43,7 @@ class ClientConnection final : public IPC::ClientConnection<AudioServerEndpoint>
, public AudioServerEndpoint {
C_OBJECT(ClientConnection)
public:
explicit ClientConnection(Core::LocalSocket&, int client_id, Mixer& mixer);
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id, Mixer& mixer);
~ClientConnection() override;
void did_finish_playing_buffer(Badge<BufferQueue>, int buffer_id);

View file

@ -49,7 +49,7 @@ int main(int, char**)
}
static int s_next_client_id = 0;
int client_id = ++s_next_client_id;
IPC::new_client_connection<AudioServer::ClientConnection>(*client_socket, client_id, mixer);
IPC::new_client_connection<AudioServer::ClientConnection>(client_socket.release_nonnull(), client_id, mixer);
};
if (pledge("stdio thread shared_buffer accept", nullptr) < 0) {