[gvfs/gnome-3-10] daemon: Set callback to avoid endless loop during unmount
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/gnome-3-10] daemon: Set callback to avoid endless loop during unmount
- Date: Wed, 3 Dec 2014 09:23:09 +0000 (UTC)
commit a7d4b2e86c303642720138a9df188df35fb8d63f
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Sun Sep 28 21:47:43 2014 +0100
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
daemon/gvfsbackend.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c
index 6f05f51..46e5f2a 100644
--- a/daemon/gvfsbackend.c
+++ b/daemon/gvfsbackend.c
@@ -792,7 +792,7 @@ typedef struct
const gchar *message;
const gchar *choices[3];
- gboolean no_more_processes;
+ gboolean completed;
GAsyncReadyCallback callback;
gpointer user_data;
@@ -801,7 +801,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;
@@ -815,7 +815,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 */
}
@@ -833,6 +833,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);
@@ -846,7 +847,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,
@@ -854,7 +855,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
@@ -868,18 +869,16 @@ 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 */
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]