[gvfs] gdbus: Use stable metadata proxy



commit 872e874b9ee1bf326c6d436151a917f8f39e31ec
Author: Tomas Bzatek <tbzatek redhat com>
Date:   Mon Jun 18 15:53:18 2012 +0200

    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.

 client/gdaemonfile.c |    1 -
 client/gdaemonvfs.c  |   36 +-----------------------------------
 2 files changed, 1 insertions(+), 36 deletions(-)
---
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index 5ab98d6..abfbae0 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 c131545..394152c 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);
         }
     }
 



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