[Pcsclite-muscle] question about locking and reconnect

Ricardo Martin rickyepoderi
Mon Jun 1 04:57:05 PDT 2015


Hi everybody,

Playing with opensc and the dnie driver I found a weird behavior. After some tests I opened the following issue in opensc github:

https://github.com/OpenSC/OpenSC/issues/475

It seems that opensc in the method sc_reset finally sends a SCardReconnect with SCARD_UNPOWER_CARD or SCARD_RESET_CARD (depending the do_cold_reset parameter). But at the end of the sc_reset function opensc performs the following:

??????? /* pcsc_reconnect unlocks card... try to lock it again if it was locked */
??????? if(old_locked)
??????????????? r = pcsc_lock(reader);

If the connection was previously locked, after the reconnect, it adds a lock again (SCardBeginTransaction is called again inside pcsc_lock). My impression is that this extra call adds one more lock in the pcsc (rContext->LockCount) which is never released, and this ends in the complete lock of the card until the current process finishes (no other process can access the card in shared mode). Every call to pcsc_reset in opensc seems to add a lost lock in pcsc (and the dnie driver calls to this reset).

I have done some little test with pcsc (with the little sample.c copied below) and it seems that SCardReconnect does not lose the locks (in any case: SCARD_SHARE_SHARED or SCARD_SHARE_EXCLUSIVE, SCARD_UNPOWER_CARD or SCARD_RESET_CARD). But, just to be sure, can anybody confirm that SCardReconnect maintains the locks (transactions)? Is the extra call done in opensc to SCardBeginTransaction needed?

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pcsclite-muscle/attachments/20150601/b54849a1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample.c
Type: text/x-csrc
Size: 2344 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pcsclite-muscle/attachments/20150601/b54849a1/attachment.c>



More information about the pcsclite-muscle mailing list