[Pcsclite-cvs-commit] r2183 - trunk/PCSC/src

Ludovic Rousseau rousseau at costa.debian.org
Wed Oct 11 09:29:31 UTC 2006


Author: rousseau
Date: 2006-10-11 09:29:31 +0000 (Wed, 11 Oct 2006)
New Revision: 2183

Modified:
   trunk/PCSC/src/winscard_svc.c
Log:
MSGRemoveContext(): do not reset the card if it is locked by by someone
else but simulate a card removal instead


Modified: trunk/PCSC/src/winscard_svc.c
===================================================================
--- trunk/PCSC/src/winscard_svc.c	2006-10-11 09:28:01 UTC (rev 2182)
+++ trunk/PCSC/src/winscard_svc.c	2006-10-11 09:29:31 UTC (rev 2183)
@@ -471,6 +471,7 @@
 			if (psContext[dwContextIndex].hCard[i] != 0)
 			{
 				PREADER_CONTEXT rContext = NULL;
+				DWORD dwLockId;
 
 				/*
 				 * Unlock the sharing
@@ -480,17 +481,28 @@
 				if (rv != SCARD_S_SUCCESS)
 					return rv;
 
+				dwLockId = rContext->dwLockId;
 				rContext->dwLockId = 0;
 
-				/*
-				 * We will use SCardStatus to see if the card has been
-				 * reset there is no need to reset each time
-				 * Disconnect is called
-				 */
+				if (psContext[dwContextIndex].hCard[i] != dwLockId) 
+				{
+					/*
+					 * if the card is locked by someone else we do not reset it
+					 * and simulate a card removal
+					 */
+					rv = SCARD_W_REMOVED_CARD;
+				}
+				else
+				{
+					/*
+					 * We will use SCardStatus to see if the card has been
+					 * reset there is no need to reset each time
+					 * Disconnect is called
+					 */
+					rv = SCardStatus(psContext[dwContextIndex].hCard[i], NULL,
+						NULL, NULL, NULL, NULL, NULL);
+				}
 
-				rv = SCardStatus(psContext[dwContextIndex].hCard[i], NULL,
-					NULL, NULL, NULL, NULL, NULL);
-
 				if (rv == SCARD_W_RESET_CARD || rv == SCARD_W_REMOVED_CARD)
 					SCardDisconnect(psContext[dwContextIndex].hCard[i],
 						SCARD_LEAVE_CARD);




More information about the Pcsclite-cvs-commit mailing list