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

rousseau at alioth.debian.org rousseau at alioth.debian.org
Wed May 23 14:03:46 UTC 2007


Author: rousseau
Date: 2007-05-23 14:03:46 +0000 (Wed, 23 May 2007)
New Revision: 2543

Modified:
   trunk/PCSC/src/readerfactory.c
   trunk/PCSC/src/readerfactory.h
Log:
add a Lock counter so that SCardBeginTransaction/SCardEndTransaction can
be nested


Modified: trunk/PCSC/src/readerfactory.c
===================================================================
--- trunk/PCSC/src/readerfactory.c	2007-05-23 08:15:36 UTC (rev 2542)
+++ trunk/PCSC/src/readerfactory.c	2007-05-23 14:03:46 UTC (rev 2543)
@@ -169,6 +169,7 @@
 	(sReadersContexts[dwContext])->dwContexts = 0;
 	(sReadersContexts[dwContext])->pthThread = 0;
 	(sReadersContexts[dwContext])->dwLockId = 0;
+	(sReadersContexts[dwContext])->LockCount = 0;
 	(sReadersContexts[dwContext])->vHandle = 0;
 	(sReadersContexts[dwContext])->pdwFeeds = NULL;
 	(sReadersContexts[dwContext])->pdwMutex = NULL;
@@ -386,6 +387,7 @@
 		(sReadersContexts[dwContextB])->dwBlockStatus = 0;
 		(sReadersContexts[dwContextB])->dwContexts = 0;
 		(sReadersContexts[dwContextB])->dwLockId = 0;
+		(sReadersContexts[dwContextB])->LockCount = 0;
 		(sReadersContexts[dwContextB])->readerState = NULL;
 		(sReadersContexts[dwContextB])->dwIdentity =
 			(dwContextB + 1) << (sizeof(DWORD) / 2) * 8;
@@ -532,6 +534,7 @@
 		sContext->dwContexts = 0;
 		sContext->dwSlot = 0;
 		sContext->dwLockId = 0;
+		sContext->LockCount = 0;
 		sContext->vHandle = 0;
 		sContext->dwIdentity = 0;
 		sContext->readerState = NULL;
@@ -1054,6 +1057,7 @@
 	if (RFCheckSharing(hCard) == SCARD_S_SUCCESS)
 	{
 		EHSetSharingEvent(rContext, 1);
+		rContext->LockCount += 1;
 		rContext->dwLockId = hCard;
 	}
 	else
@@ -1076,7 +1080,10 @@
 		return rv;
 
 	EHSetSharingEvent(rContext, 0);
-	rContext->dwLockId = 0;
+	if (rContext->LockCount > 0)
+		rContext->LockCount -= 1;
+	if (0 == rContext->LockCount)
+		rContext->dwLockId = 0;
 
 	return SCARD_S_SUCCESS;
 }

Modified: trunk/PCSC/src/readerfactory.h
===================================================================
--- trunk/PCSC/src/readerfactory.h	2007-05-23 08:15:36 UTC (rev 2542)
+++ trunk/PCSC/src/readerfactory.h	2007-05-23 14:03:46 UTC (rev 2543)
@@ -162,6 +162,7 @@
 		DWORD dwSlot;			/* Current Reader Slot */
 		DWORD dwBlockStatus;	/* Current blocking status */
 		DWORD dwLockId;			/* Lock Id */
+		int LockCount;			/* number of recursive locks */
 		DWORD dwIdentity;		/* Shared ID High Nibble */
 		int32_t dwContexts;		/* Number of open contexts */
 		PDWORD pdwFeeds;		/* Number of shared client to lib */




More information about the Pcsclite-cvs-commit mailing list