Hi,
it seems SCardReleaseContext will just return SCARD_E_NO_SERVICE and
skip removing the local context if the daemon is not running. From
pcsc-lite-1.4.99-svn-2812:
LONG SCardReleaseContext(SCARDCONTEXT hContext)
{
...
if (SCardCheckDaemonAvailability() != SCARD_S_SUCCESS)
return SCARD_E_NO_SERVICE;
...
SCardLockThread();
SCardRemoveContext(hContext);
SCardUnlockThread();
PROFILE_END
return scReleaseStruct.rv;
}
Now, an application might at a later time try to allocate a new
context successfully if the daemon ist alive again. If this happens a
couple of times, it seems like the slots for contexts will be
exhausted and SCardEstablishContext() will then fail. So wouldn't it
seem to be the proper thing to do the SCardRemoveContext() regardless
of daemon availability?
Older PCSC-Lite versions appear to have been meant to behave like I
outlined. Though in the case of winscard_clnt.c in Mac OS X 10.4.x it
didn't work because local rv was not initialized to zero:
static LONG SCardReleaseContextTH(SCARDCONTEXT hContext)
{
LONG contextIndice;
LONG rv;
/*
* Make sure this context has been opened
*/
contextIndice = SCardGetContextIndice(hContext);
if (contextIndice == -1)
return SCARD_E_INVALID_HANDLE;
/* We only need to tell pcscd about the context going away if
pcscd knows
about it in the first place. This is only the case when the
context
is connected. */
if (psContextMap[contextIndice].contextConnectStatus
== CONTEXT_STATUS_CONNECTED)
{
...
}
if (!rv)
{
psContextMap[contextIndice].hServerContext = 0;
/* Cancel any pending SCardGetStatusChange() calls. */
psContextMap[contextIndice].contextBlockStatus =
BLOCK_STATUS_RESUME;
psContextMap[contextIndice].contextConnectStatus =
CONTEXT_STATUS_FREE;
psContextMap[contextIndice].dwScope = 0;
Regards,
Eric
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle