mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
fix crashes and leaks on shutdown
This commit is contained in:
parent
f817aabe24
commit
323c644084
5 changed files with 27 additions and 5 deletions
|
|
@ -137,7 +137,7 @@ static bool refill_buffer(struct pw_protocol_native_connection *conn, struct buf
|
|||
msg.msg_iovlen = 1;
|
||||
msg.msg_control = cmsgbuf;
|
||||
msg.msg_controllen = sizeof(cmsgbuf);
|
||||
msg.msg_flags = MSG_CMSG_CLOEXEC;
|
||||
msg.msg_flags = MSG_CMSG_CLOEXEC | MSG_DONTWAIT;
|
||||
|
||||
while (true) {
|
||||
len = recvmsg(conn->fd, &msg, msg.msg_flags);
|
||||
|
|
@ -482,7 +482,7 @@ bool pw_protocol_native_connection_flush(struct pw_protocol_native_connection *c
|
|||
}
|
||||
|
||||
while (true) {
|
||||
len = sendmsg(conn->fd, &msg, MSG_NOSIGNAL);
|
||||
len = sendmsg(conn->fd, &msg, MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||
if (len < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -486,13 +486,21 @@ void pw_core_destroy(struct pw_core *core)
|
|||
{
|
||||
struct pw_global *global, *t;
|
||||
struct pw_module *module, *tm;
|
||||
struct pw_remote *remote, *tr;
|
||||
struct pw_node *node, *tn;
|
||||
|
||||
pw_log_debug("core %p: destroy", core);
|
||||
spa_hook_list_call(&core->listener_list, struct pw_core_events, destroy);
|
||||
|
||||
spa_list_for_each_safe(remote, tr, &core->remote_list, link)
|
||||
pw_remote_destroy(remote);
|
||||
|
||||
spa_list_for_each_safe(module, tm, &core->module_list, link)
|
||||
pw_module_destroy(module);
|
||||
|
||||
spa_list_for_each_safe(node, tn, &core->node_list, link)
|
||||
pw_node_destroy(node);
|
||||
|
||||
spa_list_for_each_safe(global, t, &core->global_list, link)
|
||||
pw_global_destroy(global);
|
||||
|
||||
|
|
|
|||
|
|
@ -201,6 +201,9 @@ void pw_init(int *argc, char **argv[])
|
|||
if ((str = getenv("SPA_PLUGIN_DIR")) == NULL)
|
||||
str = PLUGINDIR;
|
||||
|
||||
if (support_info.n_support > 0)
|
||||
return;
|
||||
|
||||
if (open_support(str, "support/libspa-support", &support_info))
|
||||
configure_support(&support_info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -518,6 +518,8 @@ static void clean_transport(struct pw_proxy *proxy)
|
|||
if (data->trans == NULL)
|
||||
return;
|
||||
|
||||
unhandle_socket(proxy);
|
||||
|
||||
spa_list_for_each(port, &data->node->input_ports, link) {
|
||||
spa_graph_port_remove(&data->in_ports[port->port_id].output);
|
||||
spa_graph_port_remove(&data->in_ports[port->port_id].input);
|
||||
|
|
@ -530,7 +532,6 @@ static void clean_transport(struct pw_proxy *proxy)
|
|||
free(data->in_ports);
|
||||
free(data->out_ports);
|
||||
pw_client_node_transport_destroy(data->trans);
|
||||
unhandle_socket(proxy);
|
||||
close(data->rtwritefd);
|
||||
|
||||
data->trans = NULL;
|
||||
|
|
@ -1056,6 +1057,15 @@ static void do_node_init(struct pw_proxy *proxy)
|
|||
pw_client_node_proxy_done(data->node_proxy, 0, SPA_RESULT_OK);
|
||||
}
|
||||
|
||||
static void node_destroy(void *data)
|
||||
{
|
||||
struct node_data *d = data;
|
||||
pw_log_debug("%p: destroy", d);
|
||||
pw_client_node_proxy_destroy(d->node_proxy);
|
||||
pw_proxy_destroy((struct pw_proxy *)d->node_proxy);
|
||||
d->node_proxy = NULL;
|
||||
}
|
||||
|
||||
static void node_active_changed(void *data, bool active)
|
||||
{
|
||||
struct node_data *d = data;
|
||||
|
|
@ -1065,6 +1075,7 @@ static void node_active_changed(void *data, bool active)
|
|||
|
||||
static const struct pw_node_events node_events = {
|
||||
PW_VERSION_NODE_EVENTS,
|
||||
.destroy = node_destroy,
|
||||
.active_changed = node_active_changed,
|
||||
.need_input = node_need_input,
|
||||
.have_output = node_have_output,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue