utils.muxer: remove upstream notif. iter. once ended/canceled
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 1 Jun 2017 20:27:36 +0000 (16:27 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 20:58:14 +0000 (16:58 -0400)
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 <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/utils/muxer/muxer.c

index a148ca41cbff6cf551c1ba491605b76814ee633a..04f8c535645066e25d07ffeb28cba8f8dc71c57f 100644 (file)
@@ -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:
This page took 0.026309 seconds and 4 git commands to generate.