<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1433233626859_15592">Hi again,</div><div id="yui_3_16_0_1_1433233626859_15591"><br></div><div dir="ltr" id="yui_3_16_0_1_1433233626859_15517">In my little understanding the idea behind SCardReconnect is that it is just a SCardDisconnect + SCardConnect. And, because SCardDisconnect releases any lock, SCardReconnect should also do the same. If you want to lock you need to start the transaction again just like after a normal SCardConnect (in shared mode of course).</div><div id="yui_3_16_0_1_1433233626859_16133" dir="ltr"><br></div><div id="yui_3_16_0_1_1433233626859_15985" dir="ltr">Regards!<br></div><div id="yui_3_16_0_1_1433233626859_15516"><span></span></div><br> <div id="yui_3_16_0_1_1433233626859_15766" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div id="yui_3_16_0_1_1433233626859_15765" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div id="yui_3_16_0_1_1433233626859_15764" dir="ltr"> <hr id="yui_3_16_0_1_1433233626859_15768" size="1"> <font id="yui_3_16_0_1_1433233626859_15767" size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Ludovic Rousseau <ludovic.rousseau@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> Ricardo Martin <rickyepoderi@yahoo.es>; Talks about MUSCLE <pcsclite-muscle@lists.alioth.debian.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Tuesday, June 2, 2015 11:43 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Pcsclite-muscle] question about locking and reconnect<br> </font> </div> <div id="yui_3_16_0_1_1433233626859_15769" class="y_msg_container"><br>2015-06-01 22:56 GMT+02:00 Ricardo Martin <<a shape="rect" ymailto="mailto:rickyepoderi@yahoo.es" href="mailto:rickyepoderi@yahoo.es">rickyepoderi@yahoo.es</a>>:<br clear="none">> Hi Ludovic,<br clear="none"><br clear="none">Hello,<br clear="none"><br clear="none">> I have tested a similar sample.c (attached) in a windows vista (sorry, it's<br clear="none">> the only windows I have) with Windows SDK 6.1 and it is clear that the<br clear="none">> SCardRconnect clears the connections. Compilation and output is presented<br clear="none">> below:<br clear="none">><br clear="none">> C:\Users\ricky\Desktop>cl sample.c Winscard.lib<br clear="none">> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for<br clear="none">> 80x86<br clear="none">> Copyright (C) Microsoft Corporation. All rights reserved.<br clear="none">><br clear="none">> sample.c<br clear="none">> Microsoft (R) Incremental Linker Version 9.00.21022.08<br clear="none">> Copyright (C) Microsoft Corporation. All rights reserved.<br clear="none">><br clear="none">> /out:sample.exe<br clear="none">> sample.obj<br clear="none">> Winscard.lib<br clear="none">><br clear="none">> C:\Users\ricky\Desktop>sample.exe<br clear="none">> reader name: Gemplus USB SmartCard Reader 0<br clear="none">> response: 86 CC 40 80 7A 68 C9 90 00<br clear="none">> response: 86 CC 40 80 7A 68 C9 90 00<br clear="none">> SCardEndTransaction: 0x80100016 (0x80100016)<br clear="none">><br clear="none">> So the SCardEndTransaction returns SCARD_E_NOT_TRANSACTED after the<br clear="none">> reconnect. Besides the documentation says the following:<br clear="none">><br clear="none">> "The application must immediately call the SCardDisconnect, SCardReconnect,<br clear="none">> or SCardReleaseContext function to avoid an existing transaction blocking<br clear="none">> other threads and processes from communicating with the smart card."<br clear="none">><br clear="none">> See here:<br clear="none">> <a shape="rect" href="https://msdn.microsoft.com/es-es/library/windows/desktop/aa379477%28v=vs.85%29.aspx" target="_blank">https://msdn.microsoft.com/es-es/library/windows/desktop/aa379477%28v=vs.85%29.aspx</a><br clear="none"><br clear="none">That is surprising.<br clear="none">If you use a transaction it is because you want to have an exclusive<br clear="none">access to the card.<br clear="none">You may want to reset the card using a SCardReconnect() and continue<br clear="none">using it with an exclusive access.<br clear="none"><br clear="none">Under Windows you would loose the exclusive access to the card<br clear="none">(SCardReconnect() releases the transaction). Another program could<br clear="none">start a new transaction before you can acquire an exclusive access<br clear="none">again using a new transaction.<br clear="none">With pcsc-lite you do not have this race problem.<br clear="none"><br clear="none">One solution under Windows would be to use<br clear="none">SCardReconnect(SCARD_SHARE_EXCLUSIVE) instead of transactions.<br clear="none"><br clear="none">Bye<div class="qtdSeparateBR"><br><br></div><div class="yqt1809873922" id="yqtfd22670"><br clear="none"><br clear="none">-- <br clear="none"> Dr. Ludovic Rousseau<br clear="none"><br clear="none">_______________________________________________<br clear="none">Pcsclite-muscle mailing list<br clear="none"><a shape="rect" ymailto="mailto:Pcsclite-muscle@lists.alioth.debian.org" href="mailto:Pcsclite-muscle@lists.alioth.debian.org">Pcsclite-muscle@lists.alioth.debian.org</a><br clear="none"><a shape="rect" href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle</a><br clear="none"></div><br><br></div> </div> </div> </div></body></html>