From aa48aface7043930a3b31325d6f59340b69721ff Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 13 Nov 2019 15:03:39 +0100 Subject: plugin-manager: fix waiting the minimum probing time The device port probings were being finished before the minimum probing time, making this timeout effectively useless. (cherry picked from commit 76e862597cbffd6073523eeb842a886f5d5742e9) --- src/mm-plugin-manager.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/mm-plugin-manager.c b/src/mm-plugin-manager.c index f0045af7f..fb21305dc 100644 --- a/src/mm-plugin-manager.c +++ b/src/mm-plugin-manager.c @@ -812,6 +812,15 @@ device_context_complete (DeviceContext *device_context) { GTask *task; + /* If the context is completed before the minimum probing time, we need to wait + * until that happens, so that we give enough time to udev/hotplug to report the + * new port additions. */ + if (device_context->min_probing_time_id) { + mm_dbg ("[plugin manager] task %s: all port probings completed, but not reached min probing time yet", + device_context->name); + return; + } + /* Steal the task from the context */ g_assert (device_context->task); task = device_context->task; @@ -831,15 +840,8 @@ device_context_complete (DeviceContext *device_context) device_context->released_id = 0; } - /* Remove timeouts, if still around */ - if (device_context->min_wait_time_id) { - g_source_remove (device_context->min_wait_time_id); - device_context->min_wait_time_id = 0; - } - if (device_context->min_probing_time_id) { - g_source_remove (device_context->min_probing_time_id); - device_context->min_probing_time_id = 0; - } + /* On completion, the minimum wait time must have been already elapsed */ + g_assert (!device_context->min_wait_time_id); /* Task completion */ if (!device_context->best_plugin) -- cgit v1.2.1