From 211abaef5ec5858a8e3682edfb838d995900a025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sat, 7 May 2022 14:08:55 +0200 Subject: [PATCH] protocol-native: remove destroyed client from client list When the client destroys the protocol-native module, the server and the client are destroyed but the client is still reffed (not freed). It will be unreffed after its messages are processed, after which point it will be freed and removed from the server client_list that is already destroyed. Fix this by removing the client from the server list when it is destroyed. See #565 --- src/modules/module-protocol-native.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index 6869f5c1d..556ee14c0 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -440,14 +440,19 @@ error: goto done; } +static void client_destroy(void *data) +{ + struct client_data *this = data; + pw_log_debug("%p: destroy", this); + spa_list_remove(&this->protocol_link); +} + static void client_free(void *data) { struct client_data *this = data; struct pw_impl_client *client = this->client; pw_log_debug("%p: free", this); - spa_list_remove(&this->protocol_link); - spa_hook_remove(&this->client_listener); if (this->source) @@ -460,6 +465,7 @@ static void client_free(void *data) static const struct pw_impl_client_events client_events = { PW_VERSION_IMPL_CLIENT_EVENTS, + .destroy = client_destroy, .free = client_free, .busy_changed = client_busy_changed, };