Date: Sat, 01 Sep 2018 15:20:28 +0000 From: bugzilla-noreply@freebsd.org To: usb@FreeBSD.org Subject: [Bug 231076] libusb_cancel_transfer() does NOT cancel a transfer after the USB device is removed Message-ID: <bug-231076-19105@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D231076 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: usb@FreeBSD.org Reporter: ludovic.rousseau+freebsd@gmail.com I am the author of the CCID driver: a driver for smart card readers complia= nt 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=20 /usr/local/lib/pcsc/drivers/ifd-ccid.bundle/Contents/FreeBSD/libccid.so: libusb.so.3 =3D> /usr/lib/libusb.so.3 (0x2821c000) libthr.so.3 =3D> /lib/libthr.so.3 (0x2822d000) libc.so.7 =3D> /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 timeo= ut 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_F= OUND (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. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-231076-19105>