thunderbolt-power: If a timer is still running from coldplug, stop it (#457)

A race condition is hypothesized in the following scenario:

1. User starts up the system and fwupd doesn't start automatically.
2. User manually calls fwupdmgr install blah.cab (or fwupdmgr update really) which uses dbus activation to start fwupd systemd unit.
3. This runs coldplug on thunderbolt plugin, no devices found. Thunderbolt power runs coldplug routine.
  a. This sets forcepower with a timeout to turn off after 20 seconds.
  b. Coldplug exits.
4. update routine starts
  a. Thunderbolt plugin starts flash routine.
  b. Thunderbolt power plugin turns off force power in middle of flash routine.
  c. Issue described happens.
This commit is contained in:
Mario Limonciello 2018-04-10 11:09:37 -05:00 committed by Mario Limonciello
parent 86fdd975ad
commit 0bd8c74cc0

View File

@ -229,6 +229,12 @@ fu_plugin_update_prepare (FuPlugin *plugin,
if (g_strcmp0 (fu_device_get_plugin (device), "thunderbolt") != 0)
return TRUE;
/* reset any timers that might still be running from coldplug */
if (data->timeout_id != 0) {
g_source_remove (data->timeout_id);
data->timeout_id = 0;
}
devpath = fu_device_get_metadata (device, "sysfs-path");
udevice = g_udev_client_query_by_sysfs_path (data->udev, devpath);