2fccc86ccc
This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/udisks2.git#8eb05435f07a89544f717607667b28049f1313f5
61 lines
2.0 KiB
Diff
61 lines
2.0 KiB
Diff
commit 6ff556afabd490feb6c4b29f9e91e81d64e2c0ed
|
|
Author: Tomas Bzatek <tbzatek@redhat.com>
|
|
Date: Tue Mar 23 12:56:40 2021 +0100
|
|
|
|
udiskslinuxdriveata: Use GTask to apply configuration in a thread
|
|
|
|
Should fix a leaking GThread without a need to join or track it anyhow.
|
|
|
|
diff --git a/src/udiskslinuxdriveata.c b/src/udiskslinuxdriveata.c
|
|
index 5ebdcd76..2de138cd 100644
|
|
--- a/src/udiskslinuxdriveata.c
|
|
+++ b/src/udiskslinuxdriveata.c
|
|
@@ -1625,10 +1625,13 @@ apply_conf_data_free (ApplyConfData *data)
|
|
g_free (data);
|
|
}
|
|
|
|
-static gpointer
|
|
-apply_configuration_thread_func (gpointer user_data)
|
|
+static void
|
|
+apply_configuration_thread_func (GTask *task,
|
|
+ gpointer source_object,
|
|
+ gpointer task_data,
|
|
+ GCancellable *cancellable)
|
|
{
|
|
- ApplyConfData *data = user_data;
|
|
+ ApplyConfData *data = task_data;
|
|
UDisksDaemon *daemon;
|
|
const gchar *device_file = NULL;
|
|
gint fd = -1;
|
|
@@ -1799,8 +1802,6 @@ apply_configuration_thread_func (gpointer user_data)
|
|
out:
|
|
if (fd != -1)
|
|
close (fd);
|
|
- apply_conf_data_free (data);
|
|
- return NULL;
|
|
}
|
|
|
|
/**
|
|
@@ -1819,6 +1820,7 @@ udisks_linux_drive_ata_apply_configuration (UDisksLinuxDriveAta *drive,
|
|
{
|
|
gboolean has_conf = FALSE;
|
|
ApplyConfData *data = NULL;
|
|
+ GTask *task;
|
|
|
|
data = g_new0 (ApplyConfData, 1);
|
|
data->ata_pm_standby = -1;
|
|
@@ -1862,9 +1864,10 @@ udisks_linux_drive_ata_apply_configuration (UDisksLinuxDriveAta *drive,
|
|
/* this can easily take a long time and thus block (the drive may be in standby mode
|
|
* and needs to spin up) - so run it in a thread
|
|
*/
|
|
- g_thread_new ("apply-conf-thread",
|
|
- apply_configuration_thread_func,
|
|
- data);
|
|
+ task = g_task_new (data->object, NULL, NULL, NULL);
|
|
+ g_task_set_task_data (task, data, (GDestroyNotify) apply_conf_data_free);
|
|
+ g_task_run_in_thread (task, apply_configuration_thread_func);
|
|
+ g_object_unref (task);
|
|
|
|
data = NULL; /* don't free data below */
|
|
|