[gvfs/gdbus-core: 48/49] gdbus: Gracefully handle monitoring unsubscribe on unmounted backend



commit 881ffc4130e199c95170df311a7b61d5da8a55dc
Author: Tomas Bzatek <tbzatek redhat com>
Date:   Fri Jul 27 16:59:25 2012 +0200

    gdbus: Gracefully handle monitoring unsubscribe on unmounted backend
    
    The mount may be already gone or monitoring cleanup is done too late;
    in that case handle this case gracefully since the monitoring doesn't
    exist anymore.

 client/gdaemonfilemonitor.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/client/gdaemonfilemonitor.c b/client/gdaemonfilemonitor.c
index 6b5a7fe..4b063f9 100644
--- a/client/gdaemonfilemonitor.c
+++ b/client/gdaemonfilemonitor.c
@@ -204,6 +204,13 @@ subscribe_proxy_created_cb (GVfsDBusMonitor *proxy,
 {
   AsyncProxyCreate *data = user_data;
 
+  if (proxy == NULL)
+    {
+      /* TODO: report an error? */
+      async_proxy_create_free (data);
+      return;
+    }
+  
   gvfs_dbus_monitor_call_subscribe (proxy,
                                     data->monitor->object_path,
                                     NULL,
@@ -226,14 +233,12 @@ async_proxy_new_cb (GObject *source_object,
   g_print ("gdaemonfilemonitor.c: async_proxy_new_cb, proxy = %p\n", proxy);
   if (proxy == NULL)
     {
-      g_printerr ("Error creating proxy: %s (%s, %d)\n",
+      g_printerr ("Error creating monitor proxy: %s (%s, %d)\n",
                   error->message, g_quark_to_string (error->domain), error->code);
       g_error_free (error);
-      async_proxy_create_free (data);
-      return;
     }
   
-  data->cb(proxy, data);
+  data->cb (proxy, data);
 }
 
 static void
@@ -245,6 +250,14 @@ async_got_connection_cb (GDBusConnection *connection,
   
   g_print ("gdaemonfilemonitor.c: async_got_connection_cb, connection = %p\n", connection);
 
+  if (! connection)
+    {
+      g_printerr ("Error getting connection for monitoring: %s (%s, %d)\n",
+                   io_error->message, g_quark_to_string (io_error->domain), io_error->code);
+      data->cb (NULL, data);
+      return;
+    }
+
   data->connection = g_object_ref (connection);
   gvfs_dbus_monitor_proxy_new (connection,
                                G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
@@ -303,6 +316,13 @@ unsubscribe_proxy_created_cb (GVfsDBusMonitor *proxy,
 {
   AsyncProxyCreate *data = user_data;
 
+  if (proxy == NULL)
+    {
+      /* Let's assume the target backend is gone already and there's nothing to cancel */
+      async_proxy_create_free (data);
+      return;
+    }
+  
   gvfs_dbus_monitor_call_unsubscribe (proxy,
                                       data->monitor->object_path,
                                       NULL,
@@ -318,6 +338,8 @@ g_daemon_file_monitor_cancel (GFileMonitor* monitor)
   GDaemonFileMonitor *daemon_monitor = G_DAEMON_FILE_MONITOR (monitor);
   AsyncProxyCreate *data;
   
+  g_print ("g_daemon_file_monitor_cancel\n");
+  
   data = g_new0 (AsyncProxyCreate, 1);
   data->monitor = g_object_ref (daemon_monitor);
   data->cb = unsubscribe_proxy_created_cb;



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