Collect useless graph's connections
Before this patch, the connections accumulate in the graph's array of
connections and are never destroyed until the graph is destroyed.
However, because it is possible to disconnect the ports of a connection,
it is possible that a graph contains connections that are useless. This
can cause a "leak" of connections, which would be especially experienced
with a graph that contains a source which dynamically adds and removes
many ports that are connected during its lifetime.
The conditions for a connection to be considered useless are:
1. Its reference count is 0. This means only its parent, the graph,
controls its existence.
2. Its ports are disconnected.
3. All its created notification iterators are finalized.
When all the conditions above are satisfied, it is safe to remove the
connection from its parent graph.
Conditions 2 and 3 can be checked in:
* bt_connection_disconnect_ports(): The connection is dead, detached
from its ports, and vice versa, thus satisfying condition 2.
* bt_connection_remove_iterator(): The number of notification iterators
changes; could drop to 0, thus satisfying condition 3.
To accomodate condition 1, a new concept is added to the base object: it
is possible to set a "parent is owner" listener which is called when the
parent becomes the owner of the object (that is, when the object's
reference count drops to 0 and it has a parent). Connection objects use
this callback to possibly remove itself from its parent when all three
conditions above are satisfied.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.025829 seconds and 4 git commands to generate.