diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-09-28 21:47:43 +0100 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2014-12-03 09:25:21 +0100 |
commit | 634b12a093779aac626757ab41d91ef07d7ce251 (patch) | |
tree | a6c15778825689375b0dd2eaeeab158a48dbe56d | |
parent | 4cff08d1d9c458eb3ee46a4c4326626fffcaa7a8 (diff) | |
download | gvfs-634b12a093779aac626757ab41d91ef07d7ce251.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
-rw-r--r-- | daemon/gvfsbackend.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c index e679e30d..01f55632 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 */ } @@ -834,6 +834,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); @@ -847,7 +848,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, @@ -855,7 +856,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 @@ -869,19 +870,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); } |