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

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Tue Oct 13 07:15:39 UTC 2009


Author: rousseau
Date: Tue Oct 13 07:15:32 2009
New Revision: 4487

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4487
Log:
revert changeset 4485. SCardCheckDaemonAvailability() is also used to
invalidate the PC/SC handles after a fork or a pcscd restart

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=4487&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue Oct 13 07:15:32 2009
@@ -542,6 +542,19 @@
 		return SCARD_E_INVALID_HANDLE;
 	}
 
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+	{
+		/*
+		 * Remove the local context from the stack
+		 */
+		(void)SCardLockThread();
+		(void)SCardRemoveContext(hContext);
+		(void)SCardUnlockThread();
+
+		return rv;
+	}
+
 	(void)SYS_MutexLock(psContextMap[dwContextIndex].mMutex);
 
 	/* check the context is still opened */
@@ -698,6 +711,10 @@
 	 */
 	if (strlen(szReader) > MAX_READERNAME)
 		return SCARD_E_INVALID_VALUE;
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this context has been opened
@@ -849,6 +866,10 @@
 	if (pdwActiveProtocol == NULL)
 		return SCARD_E_INVALID_PARAMETER;
 
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
+
 	/*
 	 * Make sure this handle has been opened
 	 */
@@ -945,6 +966,10 @@
 	DWORD dwContextIndex, dwChannelIndex;
 
 	PROFILE_START
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this handle has been opened
@@ -1044,6 +1069,10 @@
 	DWORD dwContextIndex, dwChannelIndex;
 
 	PROFILE_START
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this handle has been opened
@@ -1161,6 +1190,10 @@
 	 */
 	randnum = 0;
 
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
+
 	/*
 	 * Make sure this handle has been opened
 	 */
@@ -1234,6 +1267,10 @@
 	DWORD dwContextIndex, dwChannelIndex;
 
 	PROFILE_START
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this handle has been opened
@@ -1410,6 +1447,10 @@
 
 	*pcchReaderLen = 0;
 	*pcbAtrLen = 0;
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this handle has been opened
@@ -1697,6 +1738,10 @@
 	else
 		/* reader list is empty */
 		return SCARD_S_SUCCESS;
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this context has been opened
@@ -2186,6 +2231,10 @@
 	/* 0 bytes received by default */
 	if (NULL != lpBytesReturned)
 		*lpBytesReturned = 0;
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this handle has been opened
@@ -2477,6 +2526,10 @@
 	struct getset_struct scGetSetStruct;
 	DWORD dwContextIndex, dwChannelIndex;
 
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
+
 	/*
 	 * Make sure this handle has been opened
 	 */
@@ -2630,6 +2683,10 @@
 			pcbRecvLength == NULL || pioSendPci == NULL)
 		return SCARD_E_INVALID_PARAMETER;
 
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
+
 	/*
 	 * Make sure this handle has been opened
 	 */
@@ -2805,6 +2862,10 @@
 	 */
 	if (pcchReaders == NULL)
 		return SCARD_E_INVALID_PARAMETER;
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this context has been opened
@@ -2918,6 +2979,10 @@
 
 	PROFILE_START
 
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
+
 	/*
 	 * Make sure this context has been opened
 	 */
@@ -2993,6 +3058,10 @@
 	/* Multi-string with two trailing \0 */
 	const char ReaderGroup[] = "SCard$DefaultReaders\0";
 	const int dwGroups = sizeof(ReaderGroup);
+
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
 
 	/*
 	 * Make sure this context has been opened
@@ -3168,6 +3237,11 @@
 
 	rv = SCARD_S_SUCCESS;
 
+	/* Check if the _same_ server is running */
+	rv = SCardCheckDaemonAvailability();
+	if (rv != SCARD_S_SUCCESS)
+		return rv;
+
 	/*
 	 * Make sure this context has been opened
 	 */




More information about the Pcsclite-cvs-commit mailing list