diff --git a/libfprint/fp-context.c b/libfprint/fp-context.c index d4bd0000..1f322157 100644 --- a/libfprint/fp-context.c +++ b/libfprint/fp-context.c @@ -426,6 +426,7 @@ void fp_context_enumerate (FpContext *context) { FpContextPrivate *priv = fp_context_get_instance_private (context); + gboolean dispatched; gint i; g_return_if_fail (FP_IS_CONTEXT (context)); @@ -564,8 +565,19 @@ fp_context_enumerate (FpContext *context) } #endif - while (priv->pending_devices) - g_main_context_iteration (NULL, TRUE); + /* Iterate until 1. we have no pending devices, and 2. the mainloop is idle + * This takes care of processing hotplug events that happened during + * enumeration. + * This is important due to USB `persist` being turned off. At resume time, + * devices will disappear and immediately re-appear. In this situation, + * enumerate could first see the old state with a removed device resulting + * in it to not be discovered. + * As a hotplug event is seemingly emitted by the kernel immediately, we can + * simply make sure to process all events before returning from enumerate. + */ + dispatched = TRUE; + while (priv->pending_devices || dispatched) + dispatched = g_main_context_iteration (NULL, !!priv->pending_devices); } /**