[Pcsclite-cvs-commit] r5344 - /trunk/PCSC/src/winscard_clnt.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Fri Oct 22 12:37:10 UTC 2010


Author: rousseau
Date: Fri Oct 22 12:37:08 2010
New Revision: 5344

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=5344
Log:
Only SCardGetStatusChange() can be cancelled using SCardCancel()

Thanks to Jan Rochat for the bug report
https://bugs.launchpad.net/ubuntu/+source/pcsc-lite/+bug/647545

Modified:
    trunk/PCSC/src/winscard_clnt.c

Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=5344&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Fri Oct 22 12:37:08 2010
@@ -240,6 +240,7 @@
 	SCARDCONTEXT hContext;			/**< Application Context ID */
 	pthread_mutex_t * mMutex;		/**< Mutex for this context */
 	list_t channelMapList;
+	char cancellable;				/**< We are in a cancellable call */
 };
 typedef struct _psContextMap SCONTEXTMAP;
 
@@ -2119,6 +2120,9 @@
 				waitStatusStruct.timeOut = dwTime;
 				waitStatusStruct.rv = SCARD_S_SUCCESS;
 
+				/* another thread can do SCardCancel() */
+				currentContextMap->cancellable = TRUE;
+
 				rv = MessageSendWithHeader(CMD_WAIT_READER_STATE_CHANGE,
 					currentContextMap->dwClientID,
 					sizeof(waitStatusStruct), &waitStatusStruct);
@@ -2135,6 +2139,9 @@
 				rv = MessageReceiveTimeout(CMD_WAIT_READER_STATE_CHANGE,
 					&waitStatusStruct, sizeof(waitStatusStruct),
 					currentContextMap->dwClientID, dwTime);
+
+				/* another thread can do SCardCancel() */
+				currentContextMap->cancellable = FALSE;
 
 				/* timeout */
 				if (-2 == rv)
@@ -3224,6 +3231,9 @@
 	if (NULL == currentContextMap)
 		return SCARD_E_INVALID_HANDLE;
 
+	if (! currentContextMap->cancellable)
+		return SCARD_S_SUCCESS;
+
 	/* create a new connection to the server */
 	if (ClientSetupSession(&dwClientID) != 0)
 	{
@@ -3339,6 +3349,7 @@
 	Log2(PCSC_LOG_DEBUG, "Allocating new SCONTEXTMAP @%X", newContextMap);
 	newContextMap->hContext = hContext;
 	newContextMap->dwClientID = dwClientID;
+	newContextMap->cancellable = FALSE;
 
 	newContextMap->mMutex = malloc(sizeof(pthread_mutex_t));
 	if (NULL == newContextMap->mMutex)




More information about the Pcsclite-cvs-commit mailing list