Compare commits

..

1 Commits

Author SHA1 Message Date
Benjamin Berg
cb56ddba5b virtual-image: Open window for race during deactivation
This is in order to test corner cases in fprintd.
2020-10-01 14:16:22 +02:00
2 changed files with 11 additions and 30 deletions

View File

@@ -308,6 +308,15 @@ dev_deinit (FpImageDevice *dev)
fpi_device_add_timeout (FP_DEVICE (dev), 100, (FpTimeoutFunc) fpi_image_device_close_complete, NULL, NULL); fpi_device_add_timeout (FP_DEVICE (dev), 100, (FpTimeoutFunc) fpi_image_device_close_complete, NULL, NULL);
} }
static void
dev_deactivate (FpImageDevice *dev)
{
G_DEBUG_HERE ();
/* Delay result to open up the possibility of testing race conditions. */
fpi_device_add_timeout (FP_DEVICE (dev), 100, (FpTimeoutFunc) fpi_image_device_deactivate_complete, NULL, NULL);
}
static void static void
fpi_device_virtual_image_init (FpDeviceVirtualImage *self) fpi_device_virtual_image_init (FpDeviceVirtualImage *self)
{ {
@@ -331,4 +340,6 @@ fpi_device_virtual_image_class_init (FpDeviceVirtualImageClass *klass)
img_class->img_open = dev_init; img_class->img_open = dev_init;
img_class->img_close = dev_deinit; img_class->img_close = dev_deinit;
img_class->deactivate = dev_deactivate;
} }

View File

@@ -354,24 +354,6 @@ transfer_finish_cb (GObject *source_object, GAsyncResult *res, gpointer user_dat
fpi_usb_transfer_unref (transfer); fpi_usb_transfer_unref (transfer);
} }
static gboolean
transfer_cancel_cb (FpiUsbTransfer *transfer)
{
GError *error;
FpiUsbTransferCallback callback;
error = g_error_new_literal (G_IO_ERROR,
G_IO_ERROR_CANCELLED,
"Transfer was cancelled before being started");
callback = transfer->callback;
transfer->callback = NULL;
transfer->actual_length = -1;
callback (transfer, transfer->device, transfer->user_data, error);
fpi_usb_transfer_unref (transfer);
return G_SOURCE_REMOVE;
}
/** /**
* fpi_usb_transfer_submit: * fpi_usb_transfer_submit:
@@ -405,18 +387,6 @@ fpi_usb_transfer_submit (FpiUsbTransfer *transfer,
log_transfer (transfer, TRUE, NULL); log_transfer (transfer, TRUE, NULL);
/* Work around libgusb cancellation issue, see
* https://github.com/hughsie/libgusb/pull/42
* should be fixed with libgusb 0.3.7.
* Note that this is not race free, we rely on libfprint and API users
* not cancelling from a different thread here.
*/
if (cancellable && g_cancellable_is_cancelled (cancellable))
{
g_idle_add ((GSourceFunc) transfer_cancel_cb, transfer);
return;
}
switch (transfer->type) switch (transfer->type)
{ {
case FP_TRANSFER_BULK: case FP_TRANSFER_BULK: