[tracker/tracker-1.2] libtracker-miner: Handle failure to get a TrackerSparqlConnection



commit a6379cc0c996d892223743de64a43e019314b21a
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Oct 20 16:32:24 2015 +0200

    libtracker-miner: Handle failure to get a TrackerSparqlConnection
    
    We might fail to get a TrackerSparqlConnection if the session was shut
    down too early and the DBus connection closed. Since this is not a
    programming error nor an example of a broken system, let's not abort
    and use a WARNING instead of a CRITICAL.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756869

 src/libtracker-miner/tracker-file-notifier.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index b12baa2..8bd3ecb 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -714,6 +714,11 @@ sparql_contents_query_start (TrackerFileNotifier  *notifier,
        gchar *sparql;
 
        priv = notifier->priv;
+
+       if (G_UNLIKELY (priv->connection == NULL)) {
+               return;
+       }
+
        sparql = sparql_contents_compose_query (directories, n_dirs);
        tracker_sparql_connection_query_async (priv->connection,
                                               sparql,
@@ -802,6 +807,11 @@ sparql_files_query_start (TrackerFileNotifier  *notifier,
        gchar *sparql;
 
        priv = notifier->priv;
+
+       if (G_UNLIKELY (priv->connection == NULL)) {
+               return;
+       }
+
        sparql = sparql_files_compose_query (files, n_files);
        tracker_sparql_connection_query_async (priv->connection,
                                               sparql,
@@ -1376,7 +1386,7 @@ tracker_file_notifier_finalize (GObject *object)
        g_object_unref (priv->monitor);
        g_object_unref (priv->file_system);
        g_object_unref (priv->cancellable);
-       g_object_unref (priv->connection);
+       g_clear_object (&priv->connection);
 
        if (priv->current_index_root)
                root_data_free (priv->current_index_root);
@@ -1562,11 +1572,9 @@ tracker_file_notifier_init (TrackerFileNotifier *notifier)
        priv->cancellable = g_cancellable_new ();
 
        if (error) {
-               g_critical ("Could not get SPARQL connection: %s\n",
-                           error->message);
+               g_warning ("Could not get SPARQL connection: %s\n",
+                          error->message);
                g_error_free (error);
-
-               g_assert_not_reached ();
        }
 
        priv->timer = g_timer_new ();
@@ -1667,6 +1675,11 @@ tracker_file_notifier_get_file_iri (TrackerFileNotifier *notifier,
        g_return_val_if_fail (G_IS_FILE (file), NULL);
 
        priv = notifier->priv;
+
+       if (G_UNLIKELY (priv->connection == NULL)) {
+               return NULL;
+       }
+
        canonical = tracker_file_system_get_file (priv->file_system,
                                                  file,
                                                  G_FILE_TYPE_REGULAR,


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