summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2014-09-28 21:47:43 +0100
committerRoss Lagerwall <rosslagerwall@gmail.com>2014-10-17 20:22:26 +0100
commitea347458a314ef1d99ed845b514f33b8af374ad7 (patch)
treee9e1ed94335fa623a432ace6b25985a0e8f5fe04 /daemon
parent0dedf40fec26e793692d8e4d2911a157ba7203a4 (diff)
downloadgvfs-ea347458a314ef1d99ed845b514f33b8af374ad7.tar.gz
daemon: Set callback to avoid endless loop during unmount
It is not possible to respond to unmount dialog after 2 sec timeout, because the callback isn't set properly. The dialog reopens every 2 seconds until the daemon is killed. Because a dbus method is called every 2 seconds, we may get multiple replies (e.g. one normal reply and several error replies due to a closed connection). Handle this by ignoring all but the first reply. Based on a patch by Ondrej Holy. https://bugzilla.gnome.org/show_bug.cgi?id=688471
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsbackend.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c
index 633d315e..d2750dad 100644
--- a/daemon/gvfsbackend.c
+++ b/daemon/gvfsbackend.c
@@ -793,7 +793,7 @@ typedef struct
const gchar *message;
const gchar *choices[3];
- gboolean no_more_processes;
+ gboolean completed;
GAsyncReadyCallback callback;
gpointer user_data;
@@ -802,7 +802,7 @@ typedef struct
} UnmountWithOpData;
static void
-complete_unmount_with_op (UnmountWithOpData *data)
+complete_unmount_with_op (UnmountWithOpData *data, gboolean no_more_processes)
{
gboolean ret;
GSimpleAsyncResult *simple;
@@ -816,7 +816,7 @@ complete_unmount_with_op (UnmountWithOpData *data)
data->user_data,
NULL);
- if (data->no_more_processes)
+ if (no_more_processes)
{
/* do nothing, e.g. return TRUE to signal we should unmount */
}
@@ -837,6 +837,7 @@ complete_unmount_with_op (UnmountWithOpData *data)
}
}
+ data->completed = TRUE;
g_simple_async_result_set_op_res_gboolean (simple, ret);
g_simple_async_result_complete (simple);
g_object_unref (simple);
@@ -850,7 +851,7 @@ on_show_processes_reply (GMountSource *mount_source,
UnmountWithOpData *data = user_data;
/* Do nothing if we've handled this already */
- if (data->no_more_processes)
+ if (data->completed)
return;
data->ret = g_mount_source_show_processes_finish (mount_source,
@@ -858,7 +859,7 @@ on_show_processes_reply (GMountSource *mount_source,
&data->aborted,
&data->choice);
- complete_unmount_with_op (data);
+ complete_unmount_with_op (data, FALSE);
}
static gboolean
@@ -872,19 +873,17 @@ on_update_processes_timeout (gpointer user_data)
{
/* no more processes, abort mount op */
g_mount_source_abort (data->mount_source);
- data->no_more_processes = TRUE;
- complete_unmount_with_op (data);
+ complete_unmount_with_op (data, TRUE);
}
else
{
- /* ignore reply */
processes = g_vfs_daemon_get_blocking_processes (daemon);
g_mount_source_show_processes_async (data->mount_source,
data->message,
processes,
data->choices,
- NULL,
- NULL);
+ (GAsyncReadyCallback) on_show_processes_reply,
+ data);
g_array_unref (processes);
}