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

Ludovic Rousseau rousseau at costa.debian.org
Tue Apr 11 09:06:51 UTC 2006


Author: rousseau
Date: 2006-04-11 09:06:50 +0000 (Tue, 11 Apr 2006)
New Revision: 1998

Modified:
   trunk/PCSC/src/winscard_svc.c
Log:
CreateContextThread(): do not use a pointer to the argument but the
argument itself to avoid using the same value for two consecutive
threads

Thanks to Fabien Merlet for the bug report.
See http://archives.neohapsis.com/archives/dev/muscle/2006-q2/0038.html


Modified: trunk/PCSC/src/winscard_svc.c
===================================================================
--- trunk/PCSC/src/winscard_svc.c	2006-04-02 19:23:20 UTC (rev 1997)
+++ trunk/PCSC/src/winscard_svc.c	2006-04-11 09:06:50 UTC (rev 1998)
@@ -47,11 +47,6 @@
 	int protocol_major, protocol_minor;	/* Protocol number agreed between client and server*/
 } psContext[PCSCLITE_MAX_APPLICATIONS_CONTEXTS];
 
-/**
- * @brief Index of an avaiable Application Context slot in \c psContext.
- */
-static DWORD dwNextContextIndex;
-
 LONG MSGCheckHandleAssociation(SCARDHANDLE, DWORD);
 LONG MSGFunctionDemarshall(psharedSegmentMsg, DWORD);
 LONG MSGAddContext(SCARDCONTEXT, DWORD);
@@ -60,7 +55,7 @@
 LONG MSGRemoveHandle(SCARDHANDLE, DWORD);
 LONG MSGCleanupClient(DWORD);
 
-static void ContextThread(DWORD* pdwIndex);
+static void ContextThread(LPVOID pdwIndex);
 
 LONG ContextsInitialize(void)
 {
@@ -99,11 +94,9 @@
 		return SCARD_F_INTERNAL_ERROR;
 	}
 	
-	dwNextContextIndex = i;
-
 	if (SYS_ThreadCreate(&psContext[i].pthThread, THREAD_ATTR_DETACHED,
 		(PCSCLITE_THREAD_FUNCTION( )) ContextThread,
-		(LPVOID) &dwNextContextIndex) != 1)
+		(LPVOID) i) != 1)
 	{
 		SYS_CloseFile(psContext[i].dwClientID);
 		psContext[i].dwClientID = 0; 
@@ -123,14 +116,14 @@
  *
  * For each Client message a new instance of this thread is created.
  *
- * @param[in] pdwIndex Index of an avaiable Application Context slot in 
+ * @param[in] dwIndex Index of an avaiable Application Context slot in 
  * \c psContext.
  */
-static void ContextThread(DWORD* pdwIndex)
+static void ContextThread(LPVOID dwIndex)
 {
 	LONG rv;
 	sharedSegmentMsg msgStruct;
-	DWORD dwContextIndex = *pdwIndex;
+	DWORD dwContextIndex = (DWORD)dwIndex;
 
 	Log2(PCSC_LOG_DEBUG, "Thread is started: %d",
 		psContext[dwContextIndex].dwClientID);




More information about the Pcsclite-cvs-commit mailing list