[gvfs/gdbus: 11/11] gdbus: Restore method call timeouts



commit c81ce7ca5726d54328521ec909166e160869c68b
Author: Tomas Bzatek <tbzatek redhat com>
Date:   Thu Jun 2 16:58:04 2011 +0200

    gdbus: Restore method call timeouts
    
    Use G_PROXY_VOLUME_MONITOR_DBUS_TIMEOUT (30 minutes) timeout where
    applicable to match pre-gdbus volume monitor behavior.
    
    Note that I chose to wrap locking in convenient functions to avoid
    having the lock definition in a header file.

 monitor/proxy/gproxydrive.c         |   19 +++++++++++++++++++
 monitor/proxy/gproxymount.c         |    8 ++++++--
 monitor/proxy/gproxyvolume.c        |    6 ++++++
 monitor/proxy/gproxyvolumemonitor.c |   14 ++++++++++++++
 monitor/proxy/gproxyvolumemonitor.h |    4 ++++
 5 files changed, 49 insertions(+), 2 deletions(-)
---
diff --git a/monitor/proxy/gproxydrive.c b/monitor/proxy/gproxydrive.c
index bb3866d..9c180b6 100644
--- a/monitor/proxy/gproxydrive.c
+++ b/monitor/proxy/gproxydrive.c
@@ -611,6 +611,9 @@ g_proxy_drive_eject_with_operation (GDrive              *drive,
     }
 
   proxy = g_proxy_volume_monitor_get_dbus_proxy (data->drive->volume_monitor);
+  g_proxy_volume_monitor_lock_for_timeout ();
+  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), G_PROXY_VOLUME_MONITOR_DBUS_TIMEOUT);  /* 30 minute timeout */
+  
   gvfs_remote_volume_monitor_call_drive_eject (proxy,
                                                proxy_drive->id,
                                                data->cancellation_id,
@@ -619,7 +622,11 @@ g_proxy_drive_eject_with_operation (GDrive              *drive,
                                                NULL,
                                                (GAsyncReadyCallback) eject_cb,
                                                data);
+
+  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), -1);
+  g_proxy_volume_monitor_unlock_for_timeout ();
   g_object_unref (proxy);
+
   G_UNLOCK (proxy_drive);
 
  out:
@@ -756,6 +763,9 @@ g_proxy_drive_stop (GDrive              *drive,
     }
 
   proxy = g_proxy_volume_monitor_get_dbus_proxy (data->drive->volume_monitor);
+  g_proxy_volume_monitor_lock_for_timeout ();
+  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), G_PROXY_VOLUME_MONITOR_DBUS_TIMEOUT);  /* 30 minute timeout */
+
   gvfs_remote_volume_monitor_call_drive_stop (proxy,
                                               proxy_drive->id,
                                               data->cancellation_id,
@@ -764,6 +774,9 @@ g_proxy_drive_stop (GDrive              *drive,
                                               NULL,
                                               (GAsyncReadyCallback) stop_cb,
                                               data);
+  
+  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), -1);
+  g_proxy_volume_monitor_unlock_for_timeout ();
   g_object_unref (proxy);
 
   G_UNLOCK (proxy_drive);
@@ -928,6 +941,9 @@ g_proxy_drive_start (GDrive              *drive,
   data->mount_op_id = g_proxy_mount_operation_wrap (mount_operation, proxy_drive->volume_monitor);
 
   proxy = g_proxy_volume_monitor_get_dbus_proxy (data->drive->volume_monitor);
+  g_proxy_volume_monitor_lock_for_timeout ();
+  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), G_PROXY_VOLUME_MONITOR_DBUS_TIMEOUT);  /* 30 minute timeout */
+
   gvfs_remote_volume_monitor_call_drive_start (proxy,
                                                proxy_drive->id,
                                                data->cancellation_id,
@@ -936,6 +952,9 @@ g_proxy_drive_start (GDrive              *drive,
                                                NULL,
                                                (GAsyncReadyCallback) start_cb,
                                                data);
+
+  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), -1);
+  g_proxy_volume_monitor_unlock_for_timeout ();
   g_object_unref (proxy);
 
   G_UNLOCK (proxy_drive);
diff --git a/monitor/proxy/gproxymount.c b/monitor/proxy/gproxymount.c
index eaf5b55..9e27c5c 100644
--- a/monitor/proxy/gproxymount.c
+++ b/monitor/proxy/gproxymount.c
@@ -568,10 +568,11 @@ g_proxy_mount_unmount_with_operation (GMount              *mount,
     {
       data->cancellation_id = g_strdup ("");
     }
-
-  
   
   proxy = g_proxy_volume_monitor_get_dbus_proxy (proxy_mount->volume_monitor);
+  g_proxy_volume_monitor_lock_for_timeout ();
+  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), G_PROXY_VOLUME_MONITOR_DBUS_TIMEOUT);  /* 30 minute timeout */
+
   gvfs_remote_volume_monitor_call_mount_unmount (proxy,
                                                  proxy_mount->id,
                                                  data->cancellation_id,
@@ -580,6 +581,9 @@ g_proxy_mount_unmount_with_operation (GMount              *mount,
                                                  NULL,
                                                  (GAsyncReadyCallback) unmount_cb,
                                                  data);
+
+  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), -1);
+  g_proxy_volume_monitor_unlock_for_timeout ();
   g_object_unref (proxy);
 
   G_UNLOCK (proxy_mount);
diff --git a/monitor/proxy/gproxyvolume.c b/monitor/proxy/gproxyvolume.c
index e375a2c..3443910 100644
--- a/monitor/proxy/gproxyvolume.c
+++ b/monitor/proxy/gproxyvolume.c
@@ -901,6 +901,9 @@ g_proxy_volume_mount (GVolume             *volume,
       data->mount_op_id = g_proxy_mount_operation_wrap (mount_operation, proxy_volume->volume_monitor);
 
       proxy = g_proxy_volume_monitor_get_dbus_proxy (proxy_volume->volume_monitor);
+      g_proxy_volume_monitor_lock_for_timeout ();
+      g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), G_PROXY_VOLUME_MONITOR_DBUS_TIMEOUT);  /* 30 minute timeout */
+
       gvfs_remote_volume_monitor_call_volume_mount (proxy,
                                                     proxy_volume->id,
                                                     data->cancellation_id,
@@ -909,6 +912,9 @@ g_proxy_volume_mount (GVolume             *volume,
                                                     NULL,
                                                     (GAsyncReadyCallback) mount_cb,
                                                     data);
+
+      g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), -1);
+      g_proxy_volume_monitor_unlock_for_timeout ();
       g_object_unref (proxy);
 
       G_UNLOCK (proxy_volume);
diff --git a/monitor/proxy/gproxyvolumemonitor.c b/monitor/proxy/gproxyvolumemonitor.c
index 4fdbef9..6a046c9 100644
--- a/monitor/proxy/gproxyvolumemonitor.c
+++ b/monitor/proxy/gproxyvolumemonitor.c
@@ -1345,6 +1345,20 @@ g_proxy_volume_monitor_get_dbus_proxy (GProxyVolumeMonitor *volume_monitor)
   return g_object_ref (volume_monitor->proxy);
 }
 
+G_LOCK_DEFINE_STATIC(proxy_timeout);
+
+void
+g_proxy_volume_monitor_lock_for_timeout ()
+{
+  G_LOCK (proxy_timeout);
+}
+
+void
+g_proxy_volume_monitor_unlock_for_timeout ()
+{
+  G_UNLOCK (proxy_timeout);
+}
+
 static void
 register_volume_monitor (GTypeModule *type_module,
                          const char *type_name,
diff --git a/monitor/proxy/gproxyvolumemonitor.h b/monitor/proxy/gproxyvolumemonitor.h
index 137e56b..e2f4b17 100644
--- a/monitor/proxy/gproxyvolumemonitor.h
+++ b/monitor/proxy/gproxyvolumemonitor.h
@@ -74,6 +74,10 @@ GProxyMount     *g_proxy_volume_monitor_get_mount_for_id  (GProxyVolumeMonitor *
                                                           const char          *id);
 GVfsRemoteVolumeMonitor *g_proxy_volume_monitor_get_dbus_proxy (GProxyVolumeMonitor *volume_monitor);
 
+/* This is to avoid -Wunused-variable warnings when lock is defined as static in public header file */
+void             g_proxy_volume_monitor_lock_for_timeout   (void);
+void             g_proxy_volume_monitor_unlock_for_timeout (void);
+
 void g_proxy_volume_monitor_teardown_session_bus_connection (void);
 
 



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