[tracker/wip/carlosg/parallel-installable: 3/3] libtracker-sparql: Cache service name along with the subscription
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/parallel-installable: 3/3] libtracker-sparql: Cache service name along with the subscription
- Date: Sun, 5 Apr 2020 17:23:30 +0000 (UTC)
commit 4465d9c45d9345892ef21865488851a71bc110be
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Mar 23 14:27:14 2020 +0100
libtracker-sparql: Cache service name along with the subscription
The signal callback will not contain the well-known name in the sender
argument, but the internal bus name made up for the connection. Cache
the service name along in the TrackerNotifierSubscription, so we can
retrieve it in the callback without name lookups.
src/libtracker-sparql/tracker-notifier.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-notifier.c b/src/libtracker-sparql/tracker-notifier.c
index 14d6909b4..f5e626b82 100644
--- a/src/libtracker-sparql/tracker-notifier.c
+++ b/src/libtracker-sparql/tracker-notifier.c
@@ -78,6 +78,8 @@ typedef struct _TrackerNotifierEventCache TrackerNotifierEventCache;
struct _TrackerNotifierSubscription {
GDBusConnection *connection;
+ TrackerNotifier *notifier;
+ gchar *service;
guint handler_id;
};
@@ -120,14 +122,16 @@ G_DEFINE_TYPE_WITH_CODE (TrackerNotifier, tracker_notifier, G_TYPE_OBJECT,
G_ADD_PRIVATE (TrackerNotifier))
static TrackerNotifierSubscription *
-tracker_notifier_subscription_new (GDBusConnection *connection,
- guint handler_id)
+tracker_notifier_subscription_new (TrackerNotifier *notifier,
+ GDBusConnection *connection,
+ const gchar *service)
{
TrackerNotifierSubscription *subscription;
subscription = g_new0 (TrackerNotifierSubscription, 1);
subscription->connection = g_object_ref (connection);
- subscription->handler_id = handler_id;
+ subscription->notifier = notifier;
+ subscription->service = g_strdup (service);
return subscription;
}
@@ -138,6 +142,7 @@ tracker_notifier_subscription_free (TrackerNotifierSubscription *subscription)
g_dbus_connection_signal_unsubscribe (subscription->connection,
subscription->handler_id);
g_object_unref (subscription->connection);
+ g_free (subscription->service);
g_free (subscription);
}
@@ -463,7 +468,8 @@ graph_updated_cb (GDBusConnection *connection,
GVariant *parameters,
gpointer user_data)
{
- TrackerNotifier *notifier = user_data;
+ TrackerNotifierSubscription *subscription = user_data;
+ TrackerNotifier *notifier = subscription->notifier;
TrackerNotifierEventCache *cache;
GVariantIter *events;
const gchar *graph;
@@ -471,8 +477,8 @@ graph_updated_cb (GDBusConnection *connection,
g_variant_get (parameters, "(sa{ii})", &graph, &events);
- service = g_strdup_printf ("dbus:%s", sender_name);
- cache = _tracker_notifier_event_cache_new (notifier, sender_name, graph);
+ service = g_strdup_printf ("dbus:%s", subscription->service);
+ cache = _tracker_notifier_event_cache_new (notifier, service, graph);
g_free (service);
handle_events (notifier, cache, events);
@@ -630,7 +636,8 @@ tracker_notifier_signal_subscribe (TrackerNotifier *notifier,
priv = tracker_notifier_get_instance_private (notifier);
- handler_id =
+ subscription = tracker_notifier_subscription_new (notifier, connection, service);
+ subscription->handler_id =
g_dbus_connection_signal_subscribe (connection,
service,
"org.freedesktop.Tracker3.Endpoint",
@@ -639,9 +646,7 @@ tracker_notifier_signal_subscribe (TrackerNotifier *notifier,
graph,
G_DBUS_SIGNAL_FLAGS_NONE,
graph_updated_cb,
- notifier, NULL);
-
- subscription = tracker_notifier_subscription_new (connection, handler_id);
+ subscription, NULL);
g_hash_table_insert (priv->subscriptions,
GUINT_TO_POINTER (subscription->handler_id),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]