Skip to content

device: Cancel the ongoing operation when releasing the device

Marco Trevisan requested to merge wip/3v1n0/handle-release-with-operation into master

If a device is currently verifying, identifying or enrolling we may want the user to stop the operation before we actually release the device.

Otherwise we may end-up in trying to close (failing) the internal device, while fprintd is still considering the device active, causing a dead-lock (the device can't be released, but neither claimed again or stop the current action).

In fact calling Claim() -> EnrollStart() -> Release(), we would fail with the error

net.reactivated.Fprint.Error.Internal: Release failed with error: The device is still busy with another operation, please try again later. (36)"

However, if we try to call VerifyStop, after this error, we'd fail because for the fprintd logic, the device is not claimed anymore, but actually closed, and we'd need to claim it again, but... That would still cause an internal error.

To avoid this, in case Relase() is called cancel the ongoing operation, and wait until it's done before completing the release call.


Another option is instead (or even, do both!) allowing the operations, but forcing the device release with something like this in fprint_device_release:

if (priv->current_cancellable) {
	g_cancellable_cancel (priv->current_cancellable);
	while (priv->current_action != ACTION_NONE) {
		g_main_context_iteration (NULL, TRUE);
	}
}

So that this test works:

    def test_busy_device_release_on_enroll(self):
        self.device.Claim('(s)', 'testuser')
        self.device.EnrollStart('(s)', 'left-index-finger')
        self.device.Release()

However, I'd say it's probably safer to always ensure that the current operation is cleanly stopped before requesting the release.

Edited by Marco Trevisan

Merge request reports

Loading