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
This commit is contained in:
Barnabás Pőcze 2022-05-07 14:08:55 +02:00 committed by Wim Taymans
parent d506781619
commit 211abaef5e

View file

@ -440,14 +440,19 @@ error:
goto done; 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) static void client_free(void *data)
{ {
struct client_data *this = data; struct client_data *this = data;
struct pw_impl_client *client = this->client; struct pw_impl_client *client = this->client;
pw_log_debug("%p: free", this); pw_log_debug("%p: free", this);
spa_list_remove(&this->protocol_link);
spa_hook_remove(&this->client_listener); spa_hook_remove(&this->client_listener);
if (this->source) if (this->source)
@ -460,6 +465,7 @@ static void client_free(void *data)
static const struct pw_impl_client_events client_events = { static const struct pw_impl_client_events client_events = {
PW_VERSION_IMPL_CLIENT_EVENTS, PW_VERSION_IMPL_CLIENT_EVENTS,
.destroy = client_destroy,
.free = client_free, .free = client_free,
.busy_changed = client_busy_changed, .busy_changed = client_busy_changed,
}; };