mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: add ref to client while processing
Add a ref to the client while processing messages. This way we don't destroy the client if we destroy the server it is on. Fixes #1240
This commit is contained in:
parent
102b77ea03
commit
3889ea5277
1 changed files with 8 additions and 3 deletions
|
|
@ -5599,6 +5599,8 @@ on_client_data(void *data, int fd, uint32_t mask)
|
||||||
struct impl *impl = client->impl;
|
struct impl *impl = client->impl;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
client->ref++;
|
||||||
|
|
||||||
if (mask & SPA_IO_HUP) {
|
if (mask & SPA_IO_HUP) {
|
||||||
res = -EPIPE;
|
res = -EPIPE;
|
||||||
goto error;
|
goto error;
|
||||||
|
|
@ -5629,6 +5631,8 @@ on_client_data(void *data, int fd, uint32_t mask)
|
||||||
} else if (res != -EAGAIN && res != -EWOULDBLOCK)
|
} else if (res != -EAGAIN && res != -EWOULDBLOCK)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
done:
|
||||||
|
client_unref(client);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
@ -5645,6 +5649,7 @@ error:
|
||||||
client, client->name, res, spa_strerror(res));
|
client, client->name, res, spa_strerror(res));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int check_flatpak(struct client *client, int pid)
|
static int check_flatpak(struct client *client, int pid)
|
||||||
|
|
@ -5846,13 +5851,13 @@ get_runtime_dir(char *buf, size_t buflen, const char *dir)
|
||||||
void server_free(struct server *server)
|
void server_free(struct server *server)
|
||||||
{
|
{
|
||||||
struct impl *impl = server->impl;
|
struct impl *impl = server->impl;
|
||||||
struct client *c;
|
struct client *c, *t;
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: free server %p", impl, server);
|
pw_log_debug(NAME" %p: free server %p", impl, server);
|
||||||
|
|
||||||
spa_list_remove(&server->link);
|
spa_list_remove(&server->link);
|
||||||
spa_list_consume(c, &server->clients, link)
|
spa_list_for_each_safe(c, t, &server->clients, link)
|
||||||
client_free(c);
|
client_unref(c);
|
||||||
if (server->source)
|
if (server->source)
|
||||||
pw_loop_destroy_source(impl->loop, server->source);
|
pw_loop_destroy_source(impl->loop, server->source);
|
||||||
if (server->addr.ss_family == AF_UNIX && !server->activated)
|
if (server->addr.ss_family == AF_UNIX && !server->activated)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue