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

Ludovic Rousseau rousseau at alioth.debian.org
Tue Mar 6 09:49:38 CET 2007


Author: rousseau
Date: 2007-03-06 08:49:38 +0000 (Tue, 06 Mar 2007)
New Revision: 2464

Modified:
   trunk/PCSC/src/winscard_clnt.c
Log:
SCardCheckDaemonAvailability(): if the daemon is restarted we invalidate
all the existing handles so SCard functions returns
SCARD_E_INVALID_HANDLE


Modified: trunk/PCSC/src/winscard_clnt.c
===================================================================
--- trunk/PCSC/src/winscard_clnt.c	2007-03-06 08:47:53 UTC (rev 2463)
+++ trunk/PCSC/src/winscard_clnt.c	2007-03-06 08:49:38 UTC (rev 2464)
@@ -157,7 +157,13 @@
  */
 static short isExecuted = 0;
 
+
 /**
+ * creation time of pcscd PCSCLITE_PUBSHM_FILE file
+ */
+static time_t daemon_ctime = 0;
+
+/**
  * Memory mapped address used to read status information about the readers.
  * Each element in the vector \ref readerStates makes references to a part of
  * the memory mapped.
@@ -3336,7 +3342,6 @@
 {
 	LONG rv;
 	struct stat statBuffer;
-	static time_t daemon_ctime = 0;
 
 	rv = SYS_Stat(PCSCLITE_PUBSHM_FILE, &statBuffer);
 
@@ -3345,11 +3350,30 @@
 		Log1(PCSC_LOG_ERROR, "PCSC Not Running");
 		return SCARD_E_NO_SERVICE;
 	}
+
 	if (daemon_ctime)
 	{
 		if (statBuffer.st_ctime > daemon_ctime)
 		{
+			int i;
+
 			Log1(PCSC_LOG_ERROR, "PCSC restarted");
+
+			/* invalid all handles */
+			SCardLockThread();
+
+			for (i = 0; i < PCSCLITE_MAX_APPLICATION_CONTEXTS; i++)
+				if (psContextMap[i].hContext)
+					SCardCleanContext(i);
+
+			SCardUnlockThread();
+
+			/* reset pcscd status */
+			daemon_ctime = 0;
+
+			/* reset the lib */
+			SCardUnload();
+
 			return SCARD_E_NO_SERVICE;
 		}
 	}




More information about the Pcsclite-cvs-commit mailing list