From 9a42d3d9980a8d2aa46414dfb52b59e973fc5dc8 Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Mon, 10 May 2010 20:40:53 +0300 Subject: [PATCH] daemon: remove room client connections in studio graph. Fix #89 When room client in studio graph is being destroyed of room being destroyed, connections for this client need to be destroyed as well. --- daemon/cmd_delete_room.c | 3 +++ daemon/graph.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/daemon/cmd_delete_room.c b/daemon/cmd_delete_room.c index 7dac8be9..4840c0c8 100644 --- a/daemon/cmd_delete_room.c +++ b/daemon/cmd_delete_room.c @@ -145,6 +145,9 @@ found: ladish_room_destroy(room); + ladish_graph_dump(g_studio.studio_graph); + ladish_graph_dump(g_studio.jack_graph); + cmd_ptr->command.state = LADISH_COMMAND_STATE_DONE; return true; } diff --git a/daemon/graph.c b/daemon/graph.c index 323f2f4c..14ee4a10 100644 --- a/daemon/graph.c +++ b/daemon/graph.c @@ -906,6 +906,23 @@ static void ladish_graph_remove_connection_internal(struct ladish_graph * graph_ free(connection_ptr); } +static void ladish_graph_remove_port_connections(struct ladish_graph * graph_ptr, struct ladish_graph_port * port_ptr) +{ + struct list_head * node_ptr; + struct list_head * temp_node_ptr; + struct ladish_graph_connection * connection_ptr; + + list_for_each_safe(node_ptr, temp_node_ptr, &graph_ptr->connections) + { + connection_ptr = list_entry(node_ptr, struct ladish_graph_connection, siblings); + if (connection_ptr->port1_ptr == port_ptr || connection_ptr->port2_ptr == port_ptr) + { + log_info("removing connection between ports %"PRIu64" and %"PRIu64, connection_ptr->port1_ptr->id, connection_ptr->port2_ptr->id); + ladish_graph_remove_connection_internal(graph_ptr, connection_ptr); + } + } +} + static void ladish_graph_remove_port_internal( @@ -913,6 +930,8 @@ ladish_graph_remove_port_internal( struct ladish_graph_client * client_ptr, struct ladish_graph_port * port_ptr) { + ladish_graph_remove_port_connections(graph_ptr, port_ptr); + ladish_port_del_ref(port_ptr->port); list_del(&port_ptr->siblings_client);