[Pcsclite-muscle] [PATCH V3] revamp libudev hotplug

Ludovic Rousseau ludovic.rousseau at gmail.com
Fri Nov 7 10:15:45 UTC 2014


2014-11-06 22:33 GMT+01:00 Stefani Seibold <stefani at seibold.net>:
> Hi Ludovic,

Hello Stefani,

> this is a cleaned up version of your patch without the race. I moved the
> activation of the udev monitor into HPRegisterForHotplugEvents(). So the
> monitor will now started again before the scan.

Applied in revision 7033
http://lists.alioth.debian.org/pipermail/pcsclite-cvs-commit/2014-November/006588.html

> But i have no idea why this was and is a problem. To scan for USB
> devices before accepting a connection makes no difference, the USB
> devices will sooner or later appear.

Exact. But...

> A client which assumes that there are available devices when open a
> communication is wrong implemented since there are timing assumptions
> which can fail. Imaging that some other devices will be added some other
> devices to the same USB bus, then the PCSCD client could be started
> before the device was enumerated by the kernel.
>
> So if no devices are found the client must do a rescan...

Not exactly.

Since pcsc-lite 1.6.0 it is possible to start pcscd using systemd [1].
The start is made on demand when a PC/SC application is calling
SCardstablishContext().

Without the fix the pcscd daemon was started but was answering client
requests _before_ the hotplug thread was ready and the USB bus was
scanned for the first time.
So the application got SCARD_E_NO_READERS_AVAILABLE for
SCardListReaders() and exits. It is not a problem with the
application, but with pcsc-lite. The reader was present when the
application started but PC/SC failed to report it to the application.

The bug was not visible using pcsc_scan because this application will
wait and try again if no reader is present.
But the problem was reproducible using scriptor [2] because this
application just exits if no reader is present.

Thanks again for your help.

Bye,

[1] http://ludovicrousseau.blogspot.fr/2011/11/pcscd-auto-start-using-systemd.html
[2] http://ludovicrousseau.blogspot.fr/2010/05/pcsc-sample-in-scriptor.html

-- 
 Dr. Ludovic Rousseau



More information about the Pcsclite-muscle mailing list