mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
protocol: destroy clients
Destroy clients before destroying the protocol
This commit is contained in:
parent
cc95f975ce
commit
61e7218006
2 changed files with 39 additions and 36 deletions
|
|
@ -413,16 +413,16 @@ get_name(const struct pw_properties *properties)
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int impl_connect(struct pw_protocol_client *conn)
|
static int impl_connect(struct pw_protocol_client *client)
|
||||||
{
|
{
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
socklen_t size;
|
socklen_t size;
|
||||||
const char *runtime_dir, *name = NULL;
|
const char *runtime_dir, *name = NULL;
|
||||||
int name_size, fd;
|
int name_size, fd;
|
||||||
|
|
||||||
if ((runtime_dir = getenv("XDG_RUNTIME_DIR")) == NULL) {
|
if ((runtime_dir = getenv("XDG_RUNTIME_DIR")) == NULL) {
|
||||||
pw_log_error("connect failed: XDG_RUNTIME_DIR not set in the environment");
|
pw_log_error("connect failed: XDG_RUNTIME_DIR not set in the environment");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = get_name(NULL);
|
name = get_name(NULL);
|
||||||
|
|
@ -442,11 +442,10 @@ static int impl_connect(struct pw_protocol_client *conn)
|
||||||
|
|
||||||
size = offsetof(struct sockaddr_un, sun_path) + name_size;
|
size = offsetof(struct sockaddr_un, sun_path) + name_size;
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *) &addr, size) < 0) {
|
if (connect(fd, (struct sockaddr *) &addr, size) < 0)
|
||||||
goto error_close;
|
goto error_close;
|
||||||
}
|
|
||||||
|
|
||||||
return conn->connect_fd(conn, fd);
|
return pw_protocol_client_connect_fd(client, fd);
|
||||||
|
|
||||||
error_close:
|
error_close:
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
@ -457,9 +456,9 @@ static int impl_connect(struct pw_protocol_client *conn)
|
||||||
static void
|
static void
|
||||||
on_remote_data(void *data, int fd, enum spa_io mask)
|
on_remote_data(void *data, int fd, enum spa_io mask)
|
||||||
{
|
{
|
||||||
struct client *impl = data;
|
struct client *impl = data;
|
||||||
struct pw_remote *this = impl->this.remote;
|
struct pw_remote *this = impl->this.remote;
|
||||||
struct pw_protocol_native_connection *conn = impl->connection;
|
struct pw_protocol_native_connection *conn = impl->connection;
|
||||||
struct pw_core *core = pw_remote_get_core(this);
|
struct pw_core *core = pw_remote_get_core(this);
|
||||||
|
|
||||||
if (mask & (SPA_IO_ERR | SPA_IO_HUP)) {
|
if (mask & (SPA_IO_ERR | SPA_IO_HUP)) {
|
||||||
|
|
@ -548,13 +547,13 @@ static const struct pw_protocol_native_connection_events conn_events = {
|
||||||
.need_flush = on_need_flush,
|
.need_flush = on_need_flush,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int impl_connect_fd(struct pw_protocol_client *conn, int fd)
|
static int impl_connect_fd(struct pw_protocol_client *client, int fd)
|
||||||
{
|
{
|
||||||
struct client *impl = SPA_CONTAINER_OF(conn, struct client, this);
|
struct client *impl = SPA_CONTAINER_OF(client, struct client, this);
|
||||||
struct pw_remote *remote = conn->remote;
|
struct pw_remote *remote = client->remote;
|
||||||
|
|
||||||
impl->connection = pw_protocol_native_connection_new(fd);
|
impl->connection = pw_protocol_native_connection_new(fd);
|
||||||
if (impl->connection == NULL)
|
if (impl->connection == NULL)
|
||||||
goto error_close;
|
goto error_close;
|
||||||
|
|
||||||
pw_protocol_native_connection_add_listener(impl->connection,
|
pw_protocol_native_connection_add_listener(impl->connection,
|
||||||
|
|
@ -575,34 +574,34 @@ static int impl_connect_fd(struct pw_protocol_client *conn, int fd)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void impl_disconnect(struct pw_protocol_client *conn)
|
static void impl_disconnect(struct pw_protocol_client *client)
|
||||||
{
|
{
|
||||||
struct client *impl = SPA_CONTAINER_OF(conn, struct client, this);
|
struct client *impl = SPA_CONTAINER_OF(client, struct client, this);
|
||||||
struct pw_remote *remote = conn->remote;
|
struct pw_remote *remote = client->remote;
|
||||||
|
|
||||||
impl->disconnecting = true;
|
impl->disconnecting = true;
|
||||||
|
|
||||||
if (impl->source)
|
if (impl->source)
|
||||||
pw_loop_destroy_source(remote->core->main_loop, impl->source);
|
pw_loop_destroy_source(remote->core->main_loop, impl->source);
|
||||||
impl->source = NULL;
|
impl->source = NULL;
|
||||||
|
|
||||||
if (impl->connection)
|
if (impl->connection)
|
||||||
pw_protocol_native_connection_destroy(impl->connection);
|
pw_protocol_native_connection_destroy(impl->connection);
|
||||||
impl->connection = NULL;
|
impl->connection = NULL;
|
||||||
|
|
||||||
if (impl->fd != -1)
|
if (impl->fd != -1)
|
||||||
close(impl->fd);
|
close(impl->fd);
|
||||||
impl->fd = -1;
|
impl->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void impl_destroy(struct pw_protocol_client *conn)
|
static void impl_destroy(struct pw_protocol_client *client)
|
||||||
{
|
{
|
||||||
struct client *impl = SPA_CONTAINER_OF(conn, struct client, this);
|
struct client *impl = SPA_CONTAINER_OF(client, struct client, this);
|
||||||
struct pw_remote *remote = conn->remote;
|
struct pw_remote *remote = client->remote;
|
||||||
|
|
||||||
pw_loop_destroy_source(remote->core->main_loop, impl->flush_event);
|
pw_loop_destroy_source(remote->core->main_loop, impl->flush_event);
|
||||||
|
|
||||||
spa_list_remove(&conn->link);
|
spa_list_remove(&client->link);
|
||||||
free(impl);
|
free(impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -636,9 +635,13 @@ impl_new_client(struct pw_protocol *protocol,
|
||||||
static void destroy_server(struct pw_protocol_server *server)
|
static void destroy_server(struct pw_protocol_server *server)
|
||||||
{
|
{
|
||||||
struct server *s = SPA_CONTAINER_OF(server, struct server, this);
|
struct server *s = SPA_CONTAINER_OF(server, struct server, this);
|
||||||
|
struct pw_client *client, *tmp;
|
||||||
|
|
||||||
spa_list_remove(&server->link);
|
spa_list_remove(&server->link);
|
||||||
|
|
||||||
|
spa_list_for_each_safe(client, tmp, &server->client_list, protocol_link)
|
||||||
|
pw_client_destroy(client);
|
||||||
|
|
||||||
if (s->source)
|
if (s->source)
|
||||||
pw_loop_destroy_source(s->loop, s->source);
|
pw_loop_destroy_source(s->loop, s->source);
|
||||||
if (s->addr.sun_path[0])
|
if (s->addr.sun_path[0])
|
||||||
|
|
|
||||||
|
|
@ -84,15 +84,15 @@ void pw_protocol_destroy(struct pw_protocol *protocol)
|
||||||
|
|
||||||
spa_list_remove(&protocol->link);
|
spa_list_remove(&protocol->link);
|
||||||
|
|
||||||
spa_list_for_each_safe(marshal, t1, &protocol->marshal_list, link)
|
|
||||||
free(marshal);
|
|
||||||
|
|
||||||
spa_list_for_each_safe(server, t2, &protocol->server_list, link)
|
spa_list_for_each_safe(server, t2, &protocol->server_list, link)
|
||||||
pw_protocol_server_destroy(server);
|
pw_protocol_server_destroy(server);
|
||||||
|
|
||||||
spa_list_for_each_safe(client, t3, &protocol->client_list, link)
|
spa_list_for_each_safe(client, t3, &protocol->client_list, link)
|
||||||
pw_protocol_client_destroy(client);
|
pw_protocol_client_destroy(client);
|
||||||
|
|
||||||
|
spa_list_for_each_safe(marshal, t1, &protocol->marshal_list, link)
|
||||||
|
free(marshal);
|
||||||
|
|
||||||
free(protocol->name);
|
free(protocol->name);
|
||||||
|
|
||||||
free(impl);
|
free(impl);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue