mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
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:
12
src/device.c
12
src/device.c
@ -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");
|
||||
|
||||
Reference in New Issue
Block a user