https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231076
Bug ID: 231076
Summary: libusb_cancel_transfer() does NOT cancel a transfer
after the USB device is removed
Product: Base System
Version: 10.4-STABLE
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: usb
Assignee: [email protected]
Reporter: [email protected]
I am the author of the CCID driver: a driver for smart card readers compliant
to the USB CCID specification.
My driver uses /usr/lib/libusb.so.3
$ ldd /usr/local/lib/pcsc/drivers/ifd-ccid.bundle/Contents/FreeBSD/libccid.so
/usr/local/lib/pcsc/drivers/ifd-ccid.bundle/Contents/FreeBSD/libccid.so:
libusb.so.3 => /usr/lib/libusb.so.3 (0x2821c000)
libthr.so.3 => /lib/libthr.so.3 (0x2822d000)
libc.so.7 => /lib/libc.so.7 (0x2807a000)
In my driver I use a transfer on an USB interrupt pipe to wait for card
movements events (a card is inserted or removed in the reader) with a timeout
of 10 minutes.
I use the asynchronous calls of libusb. The source of my function
InterruptRead() is available at
https://github.com/LudovicRousseau/CCID/blob/master/src/ccid_usb.c#L1294
When a USB reader is removed I have to cleanup and unload the driver so it
cancels any transfer on the interrupt pipe. To do that I use
libusb_cancel_transfer() in my function InterruptStop(). see
https://github.com/LudovicRousseau/CCID/blob/master/src/ccid_usb.c#L1380
My problem is that libusb_cancel_transfer() returns with LIBUSB_ERROR_NOT_FOUND
(because the USB device has been removed and is no more present?) and the
current transfer is NOT cancelled. My driver is still blocked in the
libusb_handle_events_completed() waiting for the function to return.
I looked at the FreeBSD libusb code. The error code LIBUSB_ERROR_NOT_FOUND is
returned just at the beginning of the libusb_cancel_transfer() function at
https://github.com/freebsd/freebsd/blob/master/lib/libusb/libusb10.c#L1501
I have no patch to propose.
Maybe libusb_cancel_transfer() should try to wake up
libusb_handle_events_completed() even if the USB device is no more present.
The problem is very easy to reproduce on my side.
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "[email protected]"