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