summaryrefslogtreecommitdiff
path: root/src/libtracker-sparql/tracker-notifier.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-02-11 17:05:17 +0100
committerCarlos Garnacho <carlosg@gnome.org>2020-02-17 18:57:46 +0100
commit192bd2d5e5af5c0c66aaebc22567ff1adda7ff32 (patch)
tree7247bb69a5de05f6de17c58998abb882d973c87f /src/libtracker-sparql/tracker-notifier.c
parent6efed2b2e2f251450ac39e644163bf015c3f1fb1 (diff)
downloadtracker-192bd2d5e5af5c0c66aaebc22567ff1adda7ff32.tar.gz
libtracker-sparql: Cancel info query on notifier finalization
We are indirectly safe here as the event cache holds a ref to the notifier, but seems sensible to ensure that TrackerNotifier finalization would result in async queries bailing out.
Diffstat (limited to 'src/libtracker-sparql/tracker-notifier.c')
-rw-r--r--src/libtracker-sparql/tracker-notifier.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/libtracker-sparql/tracker-notifier.c b/src/libtracker-sparql/tracker-notifier.c
index 332483cd3..3859fb667 100644
--- a/src/libtracker-sparql/tracker-notifier.c
+++ b/src/libtracker-sparql/tracker-notifier.c
@@ -85,6 +85,7 @@ struct _TrackerNotifierPrivate {
TrackerSparqlConnection *connection;
TrackerNotifierFlags flags;
GHashTable *subscriptions; /* guint -> TrackerNotifierSubscription */
+ GCancellable *cancellable;
};
struct _TrackerNotifierEventCache {
@@ -368,12 +369,25 @@ query_extra_info_cb (GObject *object,
TrackerSparqlCursor *cursor;
TrackerNotifierEvent *event;
GSequenceIter *iter;
+ GError *error = NULL;
gint col;
gint64 id;
priv = tracker_notifier_get_instance_private (cache->notifier);
conn = TRACKER_SPARQL_CONNECTION (object);
- cursor = tracker_sparql_connection_query_finish (conn, res, NULL);
+ cursor = tracker_sparql_connection_query_finish (conn, res, &error);
+
+ if (!cursor) {
+ if (!g_error_matches (error,
+ G_IO_ERROR,
+ G_IO_ERROR_CANCELLED)) {
+ g_critical ("Could not get cursor: %s\n", error->message);
+ }
+
+ _tracker_notifier_event_cache_free (cache);
+ g_clear_error (&error);
+ return;
+ }
iter = g_sequence_get_begin_iter (cache->sequence);
@@ -416,7 +430,7 @@ tracker_notifier_query_extra_info (TrackerNotifier *notifier,
priv = tracker_notifier_get_instance_private (notifier);
tracker_sparql_connection_query_async (priv->connection, sparql,
- NULL,
+ priv->cancellable,
query_extra_info_cb,
cache);
g_free (sparql);
@@ -518,6 +532,9 @@ tracker_notifier_finalize (GObject *object)
priv = tracker_notifier_get_instance_private (TRACKER_NOTIFIER (object));
+ g_cancellable_cancel (priv->cancellable);
+ g_clear_object (&priv->cancellable);
+
if (priv->connection)
g_object_unref (priv->connection);
@@ -594,6 +611,7 @@ tracker_notifier_init (TrackerNotifier *notifier)
priv = tracker_notifier_get_instance_private (notifier);
priv->subscriptions = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) tracker_notifier_subscription_free);
+ priv->cancellable = g_cancellable_new ();
}
guint