[tracker-miners/wip/carlosg/test-error-fixes: 2/5] libtracker-miner: Disconnect from the TrackerMonitor on finalize




commit 5ea3fffc7583f37cdd9c5cd2e23690f7e4c036cf
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jul 7 23:36:24 2021 +0200

    libtracker-miner: Disconnect from the TrackerMonitor on finalize
    
    When finalizing the TrackerFileNotifier, we may presumably not hold
    the last reference to the TrackerMonitor, there may be events in
    flight not yet handled by the main thread, and these might be still
    created until the moments that TrackerMonitor itself is being finalized.
    These events hold each a reference to the TrackerMonitor that might
    make it live longer than it is expected here.
    
    Ensure to hint shutdown to the TrackerMonitor, and disconnect from
    any pending signals before finalizing it. If there are pending events
    these will be emitted into the void and freed, eventually tearing down
    the TrackerMonitor.
    
    Avoids possible crashes after finalizing the TrackerFileNotifier/Monitor,
    as these signals would poke invalid memory, or objects being finalized,
    apparently can be occasionally seen running tracker-miner-fs-test to
    exhaustion.

 src/libtracker-miner/tracker-file-notifier.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 06e9a1c63..feba7152d 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -1420,6 +1420,9 @@ tracker_file_notifier_finalize (GObject *object)
        g_clear_object (&priv->content_query);
        g_clear_object (&priv->deleted_query);
 
+       tracker_monitor_set_enabled (priv->monitor, FALSE);
+       g_signal_handlers_disconnect_by_data (priv->monitor, object);
+
        g_object_unref (priv->crawler);
        g_object_unref (priv->monitor);
        g_clear_object (&priv->connection);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]