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

Ludovic Rousseau rousseau at costa.debian.org
Tue Sep 26 16:13:24 CEST 2006


Author: rousseau
Date: 2006-09-26 14:13:21 +0000 (Tue, 26 Sep 2006)
New Revision: 2178

Modified:
   trunk/PCSC/src/winscard.c
Log:
SCardConnect() & SCardDisconnect(): wait until any transaction finishes
before going on.
This avoids the possibility to reset a card in the middle of a transaction

Thanks to Martin Paljak for the bug report


Modified: trunk/PCSC/src/winscard.c
===================================================================
--- trunk/PCSC/src/winscard.c	2006-09-26 13:43:48 UTC (rev 2177)
+++ trunk/PCSC/src/winscard.c	2006-09-26 14:13:21 UTC (rev 2178)
@@ -242,6 +242,12 @@
 		return SCARD_E_SHARING_VIOLATION;
 	}
 
+	/*
+	 * wait until a possible transaction is finished
+	 */
+	while (rContext->dwLockId != 0)
+		SYS_USleep(100);
+
 	/*******************************************
 	 *
 	 * This section tries to determine the
@@ -442,7 +448,8 @@
 	/*
 	 * Make sure no one has a lock on this reader
 	 */
-	if ((rv = RFCheckSharing(hCard)) != SCARD_S_SUCCESS)
+	rv = RFCheckSharing(hCard);
+	if (rv != SCARD_S_SUCCESS)
 		return rv;
 
 	/*
@@ -703,9 +710,17 @@
 		return SCARD_E_INVALID_VALUE;
 
 	/*
+	 * wait until a possible transaction is finished
+	 */
+	while (rContext->dwLockId != 0)
+		SYS_USleep(100);
+
+	/*
 	 * Unlock any blocks on this context
 	 */
-	RFUnlockSharing(hCard);
+	rv = RFUnlockSharing(hCard);
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	Log2(PCSC_LOG_DEBUG, "Active Contexts: %d", rContext->dwContexts);
 




More information about the Pcsclite-cvs-commit mailing list