<div dir="ltr"><div><br><div class="gmail_extra"><br><div class="gmail_quote">2017-05-08 12:47 GMT+02:00 Maximilian Stein <span dir="ltr"><<a href="mailto:maximilian.stein@secunet.com" target="_blank">maximilian.stein@secunet.com</a>></span><wbr>:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span class="gmail-m_-4004035749301955723gmail-">> Yes. It is possible.<br>
> pcsc-lite may contain bugs.<br>
<br>
</span>I'm sorry if that sounded offensive. Personally I appreciate the work<br>
and effort you put into this project very much and merely want to<br>
contribute to its further improvement.<br></blockquote><div><br></div><div>No offense.<br></div><div>I was making joke of myself :-)<br></div><div>I should have added a smiley.<br></div><div><span class="gmail-m_-4004035749301955723gmail-"></span><span class="gmail-m_-4004035749301955723gmail-"></span><br><span class="gmail-m_-4004035749301955723gmail-"></span></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span class="gmail-m_-4004035749301955723gmail-">
> I tried to reproduce the problem with the attached sample code but<br>
> without success.<br>
> I tried using the special reader "\\?PnP?\Notification" and also using<br>
> the current reader name but could not reproduce the problem. Yes, I<br>
> first applied your patch and I get the extra sleep() in pcscd.<br>
><br>
> You can change line 52 of my sample code to use the PnP reader or the<br>
> normal one.<br>
<br>
</span>On my testing machine (Xubuntu 16.04 python-pyscard installed from<br>
repos) I can reproduce the problem with the python Unit Tests and your<br>
sample code, with any value in line 52. But on another installation of<br>
Ubuntu 16.04 (self compiled pyscard) I can't reproduce it either.<br>
<br>
My patch includes a change in the lipcsclite client library which is<br>
very important to provoke the race condition. This change should produce<br>
debug output ("Waiting 2s to provoke...") when executing the test<br>
programs with env variable PCSCLITE_DEBUG=0.<br>
<br>
Did you get this additional client side debug output?<br></blockquote><div><br></div><div>I was not using the correct libpcsclite.<br></div><div>Now I can reproduce the problem using your C code.<br clear="all"></div></div><br></div>The client will not be blocked during an INFINITE time but for 60 seconds<br><a href="https://anonscm.debian.org/cgit/pcsclite/PCSC.git/tree/src/winscard_clnt.c#n1783" target="_blank">https://anonscm.debian.org/<wbr>cgit/pcsclite/PCSC.git/tree/<wbr>src/winscard_clnt.c#n1783</a><br>But that is still a bug.<br></div><div><br><br></div><div>My proposed patch is do modify removeReader() [readerfactory.c] to call EHDestroyEventHandler() _after_ RFUnInitializeReader() instead of before.<br><br></div><div>Something like:<br>--- /tmp/paqtOc_readerfactory.c 2017-05-09 15:15:23.885862634 +0200<br>+++ src/readerfactory.c 2017-05-09 15:15:21.461801253 +0200<br>@@ -615,6 +615,8 @@ LONG RFRemoveReader(const char *readerNa<br> <br> LONG removeReader(READER_CONTEXT * sContext)<br> {<br>+ RFUnInitializeReader(sContext);<br>+<br> /* Try to destroy the thread */<br> if (sContext -> pthThread)<br> (void)EHDestroyEventHandler(sContext);<br>@@ -626,8 +628,6 @@ LONG removeReader(READER_CONTEXT * sCont<br> return SCARD_E_INVALID_VALUE;<br> }<br> <br>- RFUnInitializeReader(sContext);<br>-<br> *sContext->pMutex -= 1;<br><br></div><div><br>With this patch, the problem is fixed on my side.<br></div><div>Do you confirm it also fixes the problem for you?<br><br></div><div>Thanks<br></div><div><br></div><div><div><div class="gmail_extra">-- <br><div class="gmail-m_-4004035749301955723gmail_signature"> Dr. Ludovic Rousseau</div>
</div></div></div></div>