device: Stop any further EnrollStop/VerifyStop request once we got one

In case we get concurrent requests on EnrollStart/EnrollStop we'd just
continue with the operation, making the first processed request to start
the process and the second to hang (in code before the introduction of
stoppable_action_stop()) or to crash (in the current code).

So in such case we should always check that we're not handling already
the request, by checking priv->current_cancel_invocation value.

Add tests to verify the race.
This commit is contained in:
Marco Trevisan (Treviño)
2021-01-22 18:44:14 +01:00
parent 32b70c0edc
commit 457cbd46cd
2 changed files with 41 additions and 14 deletions

View File

@ -1163,21 +1163,23 @@ can_stop_action (FprintDevice *rdev,
GError **error)
{
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
gboolean action_matches;
switch (priv->current_action)
{
case ACTION_IDENTIFY:
case ACTION_VERIFY:
if (action == ACTION_IDENTIFY || action == ACTION_VERIFY)
return TRUE;
action_matches = (action == ACTION_VERIFY || action == ACTION_IDENTIFY);
break;
default:
if (priv->current_action == action)
return TRUE;
action_matches = priv->current_action == action;
}
if (priv->current_action != ACTION_NONE)
if (action_matches && !priv->current_cancel_invocation)
return TRUE;
if (priv->current_action != ACTION_NONE || action_matches)
{
g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
"Another operation is already in progress");