[gvfs/gdbus: 11/17] gdbus: Restore method call timeouts
- From: Tomas Bzatek <tbzatek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/gdbus: 11/17] gdbus: Restore method call timeouts
- Date: Wed, 4 Apr 2012 16:30:56 +0000 (UTC)
commit 91b50bd21af6acf6df8bec4756d513a3fda88d07
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 3e9446e..581ec2a 100644
--- a/monitor/proxy/gproxydrive.c
+++ b/monitor/proxy/gproxydrive.c
@@ -635,6 +635,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,
@@ -643,7 +646,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:
@@ -780,6 +787,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,
@@ -788,6 +798,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);
@@ -952,6 +965,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,
@@ -960,6 +976,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 c2036e9..7a5d0a5 100644
--- a/monitor/proxy/gproxymount.c
+++ b/monitor/proxy/gproxymount.c
@@ -583,10 +583,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,
@@ -595,6 +596,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 c616812..f433718 100644
--- a/monitor/proxy/gproxyvolume.c
+++ b/monitor/proxy/gproxyvolume.c
@@ -917,6 +917,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,
@@ -925,6 +928,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 ed823ed..82a813e 100644
--- a/monitor/proxy/gproxyvolumemonitor.c
+++ b/monitor/proxy/gproxyvolumemonitor.c
@@ -1325,6 +1325,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]