From e1e3f6955e389d83568b6135e794c720e1c4acef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 28 Jan 2021 00:54:34 +0100 Subject: [PATCH] virtual-device: Remove messages we can't process from queue when not scanning Commands that are not valid for non-scan operations should be removed from queue, or these may be re-proposed forever. --- libfprint/drivers/virtual-device.c | 6 +++++- tests/virtual-device.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libfprint/drivers/virtual-device.c b/libfprint/drivers/virtual-device.c index 6a321f6..6f83a05 100644 --- a/libfprint/drivers/virtual-device.c +++ b/libfprint/drivers/virtual-device.c @@ -164,7 +164,11 @@ process_cmds (FpDeviceVirtualDevice * self, /* If we are not scanning, then we have to stop here. */ if (!scan) - break; + { + g_warning ("Could not process command: %s", cmd); + g_ptr_array_remove_index (self->pending_commands, 0); + break; + } if (g_str_has_prefix (cmd, SCAN_CMD_PREFIX)) { diff --git a/tests/virtual-device.py b/tests/virtual-device.py index c8cae88..941b30c 100644 --- a/tests/virtual-device.py +++ b/tests/virtual-device.py @@ -556,6 +556,12 @@ class VirtualDevice(unittest.TestCase): self.assertFalse(self._verify_completed) self.cancel_verify() + # Since we don't really cancel here, next command will be passed to release + self._close_on_teardown = False + with GLibErrorMessage('libfprint-virtual_device', + GLib.LogLevelFlags.LEVEL_WARNING, 'Could not process command: SCAN *'): + self.dev.close_sync() + def test_device_sleep_before_completing_verify(self): enrolled = self.enroll_print('foo-print', FPrint.Finger.LEFT_RING)