summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2012-06-18 15:53:18 +0200
committerTomas Bzatek <tbzatek@redhat.com>2012-06-18 15:53:18 +0200
commit872e874b9ee1bf326c6d436151a917f8f39e31ec (patch)
tree3dcb5540ed1a5fe45b6d82760eff7074535f0c32
parent7b93a7f8486bad5886c75045aa4ec3806e8398f4 (diff)
downloadgvfs-872e874b9ee1bf326c6d436151a917f8f39e31ec.tar.gz
gdbus: Use stable metadata proxy
When GDBusProxy is constructed for a well-known name, it tracks the name owner itself and no recreation when it changes is necessary. When name owner is lost, an autostart attempt is made on a next call. This patch removes name watching completely but retains metadata proxy creation on a first use.
-rw-r--r--client/gdaemonfile.c1
-rw-r--r--client/gdaemonvfs.c36
2 files changed, 1 insertions, 36 deletions
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index 5ab98d66..abfbae0f 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -2266,7 +2266,6 @@ set_metadata_attribute (GFile *file,
res = FALSE;
g_variant_builder_unref (builder);
- g_object_unref (proxy);
}
meta_tree_unref (tree);
diff --git a/client/gdaemonvfs.c b/client/gdaemonvfs.c
index c1315450..394152c4 100644
--- a/client/gdaemonvfs.c
+++ b/client/gdaemonvfs.c
@@ -1283,26 +1283,10 @@ _g_daemon_vfs_append_metadata_for_set (GVariantBuilder *builder,
return res;
}
-static void
-metadata_daemon_vanished (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- guint *watcher_id = user_data;
-
- G_LOCK (metadata_proxy);
- g_clear_object (&metadata_proxy);
- G_UNLOCK (metadata_proxy);
-
- if (*watcher_id > 0)
- g_bus_unwatch_name (*watcher_id);
-}
-
GVfsMetadata *
_g_daemon_vfs_get_metadata_proxy (GCancellable *cancellable, GError **error)
{
GVfsMetadata *proxy;
- guint *watcher_id;
G_LOCK (metadata_proxy);
@@ -1315,24 +1299,9 @@ _g_daemon_vfs_get_metadata_proxy (GCancellable *cancellable, GError **error)
G_VFS_DBUS_METADATA_PATH,
cancellable,
error);
-
- if (proxy != NULL)
- {
- /* a place in memory to store the returned ID in */
- watcher_id = g_malloc0 (sizeof (guint));
- *watcher_id = g_bus_watch_name_on_connection (g_dbus_proxy_get_connection (G_DBUS_PROXY (proxy)),
- G_VFS_DBUS_METADATA_NAME,
- G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
- NULL,
- metadata_daemon_vanished,
- watcher_id,
- g_free);
- }
}
- if (metadata_proxy != NULL)
- /* take the reference so that we don't need to protect returned object against racy metadata_daemon_vanished() */
- proxy = g_object_ref (metadata_proxy);
+ proxy = metadata_proxy;
G_UNLOCK (metadata_proxy);
@@ -1453,7 +1422,6 @@ g_daemon_vfs_local_file_set_attributes (GVfs *vfs,
meta_lookup_cache_free (cache);
meta_tree_unref (tree);
g_free (tree_path);
- g_object_unref (proxy);
}
}
@@ -1495,7 +1463,6 @@ g_daemon_vfs_local_file_removed (GVfs *vfs,
/* flush the call with the expense of sending all queued messages on the connection */
g_dbus_connection_flush_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (proxy)),
NULL, NULL);
- g_object_unref (proxy);
}
meta_tree_unref (tree);
@@ -1544,7 +1511,6 @@ g_daemon_vfs_local_file_moved (GVfs *vfs,
/* flush the call with the expense of sending all queued messages on the connection */
g_dbus_connection_flush_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (proxy)),
NULL, NULL);
- g_object_unref (proxy);
}
}