2012/9/12 Torsten Hilbrich <[email protected]>:
> We are using pcscd version 1.4.102 in a project and got a race condition
> there. This race condition is likely to be also present in 1.8.5, as the
> code regarding hLockId is very similar.
> However, I was not yet able to reproduce the problem there.

I changed the way reader removal event are processed in version 1.8.5.

> The problem occured quite seldom if an USB-based smartcard reader (used
> via libccid version 1.3.8) is removed. Then the value dwLockId is set to
> 0xffff within EHDestroyEventHandler() to inform the
> EHStatusHandlerThread() to stop operation.
>
> However, in some cases the EHStatusHandlerThread() never exited. This
> resulted in no new chipcard reader being recognized, likely because the
> thread scanning for new readers hanging in SYS_ThreadJoin/pthread_join.
>
> In our user szenario where the smartcard is used to grant access to the
> system the only solution was to turn of the system.
>
> I did some test runs and identified the function MSGRemoveContext() as
> the place where the value of dwLockId was changed from 0xffff to 0, so
> that the thread never had a chance of seing this value. On average,
> about 50 smartcard reader removals were required to trigger the problem.

MSGRemoveContext() is called (indirectly) by SCardReleaseContext().

I guess you removed the reader while the application was calling
SCardReleaseContext(). This problem has been fixed in version 1.8.5
(in revision 6388).

After looking at the code again I found (and fixed) bugs in the
reference count management.

> During the removal some clients were reading card information involving
> some transactions with SCardBeginTransaction.
>
> I worked around the problem introducing an additional signalling
> variable to the reader context. That variable is set and queried in
> addition to dwLockId (and was succesful in exiting the thread even if
> dwLockId was reset to 0 in the meantime).
>
> See the attached patch on how this workaround was implemented.

Thanks for the patch idea.
I made hLockId volatile in revision 6458.

Bye

-- 
 Dr. Ludovic Rousseau
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle

Reply via email to