From 744ba28bbbc1289a2128ed846fcab24d0ccaba95 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 1 Jun 2017 16:27:36 -0400 Subject: [PATCH] utils.muxer: remove upstream notif. iter. once ended/canceled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This was not a bug, but it was a source of leak during the graph's lifetime (upstream notification iterator does not exist anymore but utils.muxer notification iterator keeps a structure associated to it.) Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- plugins/utils/muxer/muxer.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plugins/utils/muxer/muxer.c b/plugins/utils/muxer/muxer.c index a148ca41..04f8c535 100644 --- a/plugins/utils/muxer/muxer.c +++ b/plugins/utils/muxer/muxer.c @@ -62,9 +62,6 @@ struct muxer_upstream_notif_iter { /* Owned by this, NULL if ended */ struct bt_notification_iterator *notif_iter; - /* Weak */ - struct bt_private_port *priv_port; - /* * This flag is true if the upstream notification iterator's * current notification must be considered for the multiplexing @@ -134,7 +131,6 @@ struct muxer_upstream_notif_iter *muxer_notif_iter_add_upstream_notif_iter( } muxer_upstream_notif_iter->notif_iter = bt_get(notif_iter); - muxer_upstream_notif_iter->priv_port = priv_port; muxer_upstream_notif_iter->is_valid = false; g_ptr_array_add(muxer_notif_iter->muxer_upstream_notif_iters, muxer_upstream_notif_iter); @@ -706,6 +702,21 @@ enum bt_notification_iterator_status validate_muxer_upstream_notif_iters( if (status != BT_NOTIFICATION_ITERATOR_STATUS_OK) { goto end; } + + /* + * Remove this muxer upstream notification iterator + * if it's ended or canceled. + */ + if (!muxer_upstream_notif_iter->notif_iter) { + /* + * Use g_ptr_array_remove_fast() because the + * order of those elements is not important. + */ + g_ptr_array_remove_index_fast( + muxer_notif_iter->muxer_upstream_notif_iters, + i); + i--; + } } end: -- 2.34.1