2009/12/1 Martin Paljak <[email protected]>:
> On 01.12.2009, at 9:57, Ludovic Rousseau wrote:
>> 2009/11/30 Martin Paljak <[email protected]>:
>>> What is the status of multithreaded access to pcsc-lite? Is it supposed to 
>>> work?
>>
>> Yes. But each thread needs to have its own context. You shall call
>> SCardEstablishContext() in the newly created thread and you program
>> should work (not yet tested with your sample).
> OK, I noticed the comment in SCardEstablichContext documentation of 
> pcsc-lite: Each thread of an application shall use its own SCARDCONTEXT.
>
> Apparently other calls work (in sequential mode?) so that it has not been 
> noticed before. In theory is it important to call SCardEstablishContext for 
> every thread and every API call or in real life it only affects cases like 
> SCardGetStatusChange with infinite timeout?

All PC/SC calls of a same context will use the same mutex. So if the
calls are sequential they will just work. But if one call blocks
(SCardGetStatusChange with infinite timeout) then the other calls Will
also block.

> It is not straightforward to fix the situation in OpenSC(PKCS#11) either, as 
> there is no way to know in PKCS#11 if a new thread has been started than to 
> keep a list of existing thread id-s and check that one of the id-s maches for 
> every pcsc-lite call and manage a list of context handles as well..

Is PKCS#11 supposed to support threads?

> Although not necessary for SCardGetStatusChange (which only requires a 
> context handle), if the requirement would be true for all API calls, then 
> every new thread would also have to make the full connection establishment to 
> be able to talk to the card?

I don't think it is a good idea to have two threads talking to the
same card at the same time. But pcsc-lite will/should handle that.

Bye

-- 
 Dr. Ludovic Rousseau

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

Reply via email to