Skip to content

Commit

Permalink
lvm2: Only install results of most recently started vgs_task_func
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed Apr 5, 2022
1 parent b4a260a commit 705bc05
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/lvm2/udiskslinuxmodulelvm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ struct _UDisksLinuxModuleLVM2 {

gint delayed_update_id;
gboolean coldplug_done;

gint vgs_task_id;
};

typedef struct _UDisksLinuxModuleLVM2Class UDisksLinuxModuleLVM2Class;
Expand Down Expand Up @@ -221,6 +223,12 @@ lvm_update_vgs (GObject *source_obj,
gpointer key, value;
const gchar *vg_name;

if (GPOINTER_TO_INT (user_data) != module->vgs_task_id)
{
vgs_pvs_data_free (data);
return;
}

if (! data)
{
if (error)
Expand Down Expand Up @@ -303,11 +311,13 @@ lvm_update (UDisksLinuxModuleLVM2 *module)
{
GTask *task;

module->vgs_task_id++;

/* the callback (lvm_update_vgs) is called in the default main loop (context) */
task = g_task_new (module,
NULL /* cancellable */,
lvm_update_vgs,
NULL /* callback_data */);
GINT_TO_POINTER (module->vgs_task_id));

/* holds a reference to 'task' until it is finished */
g_task_run_in_thread (task, (GTaskThreadFunc) vgs_task_func);
Expand Down

0 comments on commit 705bc05

Please sign in to comment.