[gnome-disk-utility/kailueke/wait-for-udisks-unmount] Wait until UDisks updates the unmounted filesystem



commit a8d556dc7b756ad7a2abc96362ad71c4c5343e87
Author: Kai Lüke <kailueke riseup net>
Date:   Fri Mar 6 00:23:44 2020 +0100

    Wait until UDisks updates the unmounted filesystem
    
    Before the Filesystem.Unmount method returns it does
    not make sure that the mount point is removed from
    the list stored as filesystem property.
    I solved this once with a waiter in
    https://github.com/storaged-project/udisks/pull/574
    but since a couple of months the error is back.
    Work around this in GNOME Disks by waiting
    until the property has changed (i.e., the list has
    a different size). Just in case something else gets
    messed up, a timeout of 5 seconds is added, too.

 src/libgdu/gduutils.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/libgdu/gduutils.c b/src/libgdu/gduutils.c
index bff70304..91b6a0a9 100644
--- a/src/libgdu/gduutils.c
+++ b/src/libgdu/gduutils.c
@@ -1351,6 +1351,7 @@ typedef struct
   GList *object_iter;
   GTask *task;
   GCancellable *cancellable; /* borrowed ref */
+  guint last_mount_point_list_size; /* only for unuse_unmount_cb to check against a race in UDisks */
 } UnuseData;
 
 static void
@@ -1399,6 +1400,15 @@ unuse_unmount_cb (UDisksFilesystem *filesystem,
     }
   else
     {
+      gint64 begin_usec;
+
+      begin_usec = g_get_monotonic_time ();
+
+      while (g_strv_length ((gchar **) udisks_filesystem_get_mount_points (filesystem)) == 
data->last_mount_point_list_size
+             && g_get_monotonic_time () < begin_usec + G_USEC_PER_SEC * 5) {
+        udisks_client_settle (data->client);
+      }
+
       unuse_data_iterate (data);
     }
 }
@@ -1492,6 +1502,10 @@ unuse_data_iterate (UnuseData *data)
 
   if (filesystem_to_unmount != NULL)
     {
+      const gchar *const *mount_points;
+
+      mount_points = udisks_filesystem_get_mount_points (filesystem_to_unmount);
+      data->last_mount_point_list_size = g_strv_length ((gchar **) mount_points);
       udisks_filesystem_call_unmount (filesystem_to_unmount,
                                       g_variant_new ("a{sv}", NULL), /* options */
                                       data->cancellable, /* cancellable */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]