neil / rpms / udisks2

Forked from rpms/udisks2 a year ago
Clone

Blame SOURCES/udisks-2.9.1-daemon-Always-flush-interface-property-changes.patch

20ccde
From e039516b103eb9749a3e261c5ee1a9bc110676cf Mon Sep 17 00:00:00 2001
20ccde
From: Tomas Bzatek <tbzatek@redhat.com>
20ccde
Date: Fri, 26 Jun 2020 17:42:32 +0200
20ccde
Subject: [PATCH 1/8] daemon: Always flush interface property changes
20ccde
20ccde
Setting properties on a GDBusInterfaceSkeleton from the main thread
20ccde
as a result of uevent is somewhat racy to clients that are waiting
20ccde
for a method call to return that is processed in a separate thread
20ccde
by the daemon. Perhaps there's a race in the GDBus worker thread
20ccde
that processes changes from both threads and send them out on the bus.
20ccde
20ccde
Explicit flush on GDBusInterfaceSkeleton interfaces seems to fix
20ccde
the issue. Such approach was used before on some places, this change
20ccde
adds explicit flushes at all places where properties may change.
20ccde
---
20ccde
 src/udiskslinuxblock.c          | 2 ++
20ccde
 src/udiskslinuxdrive.c          | 1 +
20ccde
 src/udiskslinuxdriveata.c       | 5 +++++
20ccde
 src/udiskslinuxencrypted.c      | 5 +++++
20ccde
 src/udiskslinuxfilesystem.c     | 3 +++
20ccde
 src/udiskslinuxloop.c           | 1 +
20ccde
 src/udiskslinuxmdraid.c         | 1 +
20ccde
 src/udiskslinuxpartition.c      | 2 ++
20ccde
 src/udiskslinuxpartitiontable.c | 1 +
20ccde
 src/udiskslinuxswapspace.c      | 1 +
20ccde
 10 files changed, 22 insertions(+)
20ccde
20ccde
diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c
20ccde
index ddc7fe1f..34d73f0e 100644
20ccde
--- a/src/udiskslinuxblock.c
20ccde
+++ b/src/udiskslinuxblock.c
20ccde
@@ -893,6 +893,7 @@ update_configuration (UDisksLinuxBlock  *block,
20ccde
       configuration = g_variant_new ("a(sa{sv})", NULL);
20ccde
     }
20ccde
   udisks_block_set_configuration (UDISKS_BLOCK (block), configuration);
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (block));
20ccde
 }
20ccde
 
20ccde
 #ifdef HAVE_LIBMOUNT_UTAB
20ccde
@@ -1280,6 +1281,7 @@ udisks_linux_block_update (UDisksLinuxBlock       *block,
20ccde
   update_mdraid (block, device, drive, object_manager);
20ccde
 
20ccde
  out:
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (block));
20ccde
   if (device != NULL)
20ccde
     g_object_unref (device);
20ccde
   if (drive != NULL)
20ccde
diff --git a/src/udiskslinuxdrive.c b/src/udiskslinuxdrive.c
20ccde
index e9dd7117..28a90ce9 100644
20ccde
--- a/src/udiskslinuxdrive.c
20ccde
+++ b/src/udiskslinuxdrive.c
20ccde
@@ -950,6 +950,7 @@ udisks_linux_drive_update (UDisksLinuxDrive       *drive,
20ccde
   ret = update_configuration (drive, object);
20ccde
 
20ccde
  out:
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (drive));
20ccde
   if (device != NULL)
20ccde
     g_clear_object (&device);
20ccde
 
20ccde
diff --git a/src/udiskslinuxdriveata.c b/src/udiskslinuxdriveata.c
20ccde
index d65f3254..4ba66d09 100644
20ccde
--- a/src/udiskslinuxdriveata.c
20ccde
+++ b/src/udiskslinuxdriveata.c
20ccde
@@ -339,6 +339,8 @@ udisks_linux_drive_ata_update (UDisksLinuxDriveAta    *drive,
20ccde
   update_security (drive, device);
20ccde
 
20ccde
  out:
20ccde
+  /* ensure property changes are sent before the method return */
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (drive));
20ccde
   if (device != NULL)
20ccde
     g_object_unref (device);
20ccde
 
20ccde
@@ -681,6 +683,9 @@ udisks_linux_drive_ata_refresh_smart_sync (UDisksLinuxDriveAta  *drive,
20ccde
   /* update stats again to account for the IO we just did to read the SMART info */
20ccde
   update_io_stats (drive, device);
20ccde
 
20ccde
+  /* ensure property changes are sent before the method return */
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (drive));
20ccde
+
20ccde
  out:
20ccde
   g_clear_object (&device);
20ccde
   if (d != NULL)
20ccde
diff --git a/src/udiskslinuxencrypted.c b/src/udiskslinuxencrypted.c
20ccde
index 73c78873..8a230fda 100644
20ccde
--- a/src/udiskslinuxencrypted.c
20ccde
+++ b/src/udiskslinuxencrypted.c
20ccde
@@ -237,6 +237,8 @@ udisks_linux_encrypted_update (UDisksLinuxEncrypted   *encrypted,
20ccde
     update_metadata_size (encrypted, object);
20ccde
 
20ccde
   udisks_linux_block_encrypted_unlock (block);
20ccde
+
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (encrypted));
20ccde
 }
20ccde
 
20ccde
 /* ---------------------------------------------------------------------------------------------------- */
20ccde
@@ -630,6 +632,9 @@ handle_unlock (UDisksEncrypted        *encrypted,
20ccde
                                         g_udev_device_get_sysfs_attr (cleartext_device->udev_device, "dm/uuid"),
20ccde
                                         caller_uid);
20ccde
 
20ccde
+  /* ensure property changes are sent before the method return */
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (encrypted));
20ccde
+
20ccde
   udisks_encrypted_complete_unlock (encrypted,
20ccde
                                     invocation,
20ccde
                                     g_dbus_object_get_object_path (G_DBUS_OBJECT (cleartext_object)));
20ccde
diff --git a/src/udiskslinuxfilesystem.c b/src/udiskslinuxfilesystem.c
20ccde
index 669fc40b..3ae11c32 100644
20ccde
--- a/src/udiskslinuxfilesystem.c
20ccde
+++ b/src/udiskslinuxfilesystem.c
20ccde
@@ -277,6 +277,8 @@ udisks_linux_filesystem_update (UDisksLinuxFilesystem  *filesystem,
20ccde
   if (! skip_fs_size)
20ccde
     udisks_filesystem_set_size (UDISKS_FILESYSTEM (filesystem), get_filesystem_size (object));
20ccde
 
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (filesystem));
20ccde
+
20ccde
   g_object_unref (device);
20ccde
 }
20ccde
 
20ccde
@@ -1865,6 +1867,7 @@ handle_resize (UDisksFilesystem      *filesystem,
20ccde
                                                  UDISKS_DEFAULT_WAIT_TIMEOUT);
20ccde
 
20ccde
   udisks_filesystem_set_size (filesystem, get_filesystem_size (UDISKS_LINUX_BLOCK_OBJECT (object)));
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (filesystem));
20ccde
   udisks_filesystem_complete_resize (filesystem, invocation);
20ccde
   udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), TRUE, NULL);
20ccde
 
20ccde
diff --git a/src/udiskslinuxloop.c b/src/udiskslinuxloop.c
20ccde
index 6c8a4561..5d7e3553 100644
20ccde
--- a/src/udiskslinuxloop.c
20ccde
+++ b/src/udiskslinuxloop.c
20ccde
@@ -187,6 +187,7 @@ udisks_linux_loop_update (UDisksLinuxLoop        *loop,
20ccde
     }
20ccde
   udisks_loop_set_setup_by_uid (UDISKS_LOOP (loop), setup_by_uid);
20ccde
 
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (loop));
20ccde
   g_object_unref (device);
20ccde
 }
20ccde
 
20ccde
diff --git a/src/udiskslinuxmdraid.c b/src/udiskslinuxmdraid.c
20ccde
index 85fc2a3b..7eca9764 100644
20ccde
--- a/src/udiskslinuxmdraid.c
20ccde
+++ b/src/udiskslinuxmdraid.c
20ccde
@@ -512,6 +512,7 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid       *mdraid,
20ccde
                                                                                 uuid));
20ccde
 
20ccde
  out:
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (mdraid));
20ccde
   if (raid_data)
20ccde
       bd_md_examine_data_free (raid_data);
20ccde
   g_free (sync_completed);
20ccde
diff --git a/src/udiskslinuxpartition.c b/src/udiskslinuxpartition.c
20ccde
index 97ba02fe..ff0fdfc0 100644
20ccde
--- a/src/udiskslinuxpartition.c
20ccde
+++ b/src/udiskslinuxpartition.c
20ccde
@@ -312,6 +312,8 @@ udisks_linux_partition_update (UDisksLinuxPartition   *partition,
20ccde
   udisks_partition_set_is_container (UDISKS_PARTITION (partition), is_container);
20ccde
   udisks_partition_set_is_contained (UDISKS_PARTITION (partition), is_contained);
20ccde
 
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (partition));
20ccde
+
20ccde
   g_free (name);
20ccde
   g_clear_object (&device);
20ccde
   g_clear_object (&disk_block_object);
20ccde
diff --git a/src/udiskslinuxpartitiontable.c b/src/udiskslinuxpartitiontable.c
20ccde
index b26849bc..e43a0708 100644
20ccde
--- a/src/udiskslinuxpartitiontable.c
20ccde
+++ b/src/udiskslinuxpartitiontable.c
20ccde
@@ -146,6 +146,7 @@ udisks_linux_partition_table_update (UDisksLinuxPartitionTable  *table,
20ccde
 
20ccde
   udisks_partition_table_set_partitions (UDISKS_PARTITION_TABLE (table),
20ccde
                                          partition_object_paths);
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (table));
20ccde
 
20ccde
 
20ccde
   g_free (partition_object_paths);
20ccde
diff --git a/src/udiskslinuxswapspace.c b/src/udiskslinuxswapspace.c
20ccde
index ee103528..bb47f3d4 100644
20ccde
--- a/src/udiskslinuxswapspace.c
20ccde
+++ b/src/udiskslinuxswapspace.c
20ccde
@@ -127,6 +127,7 @@ udisks_linux_swapspace_update (UDisksLinuxSwapspace   *swapspace,
20ccde
     active = TRUE;
20ccde
   udisks_swapspace_set_active (UDISKS_SWAPSPACE (swapspace), active);
20ccde
 
20ccde
+  g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (swapspace));
20ccde
   g_object_unref (device);
20ccde
 }
20ccde
 
20ccde
-- 
20ccde
2.26.2
20ccde