[gvfs/gnome-3-12] daemon: Set callback to avoid endless loop during unmount



commit 6d51022f5af92fcbb05eace1a850f0ef72294cc8
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 447242b..3cceb0e 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,18 +870,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]