[Pcsclite-cvs-commit] r3146 - /trunk/PCSC/src/ifdwrapper.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Wed Sep 24 14:10:39 UTC 2008


Author: rousseau
Date: Wed Sep 24 14:10:39 2008
New Revision: 3146

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3146
Log:
IFDCloseIFD(): give up to 500 ms to the mutex to be free if the lock
failed. Maybe a polling thread is still using the device on another
slot.

Modified:
    trunk/PCSC/src/ifdwrapper.c

Modified: trunk/PCSC/src/ifdwrapper.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/ifdwrapper.c?rev=3146&op=diff
==============================================================================
--- trunk/PCSC/src/ifdwrapper.c (original)
+++ trunk/PCSC/src/ifdwrapper.c Wed Sep 24 14:10:39 2008
@@ -188,6 +188,7 @@
 LONG IFDCloseIFD(PREADER_CONTEXT rContext)
 {
 	RESPONSECODE rv = IFD_SUCCESS;
+	int repeat;
 
 #ifndef PCSCLITE_STATIC_DRIVER
 	RESPONSECODE(*IO_close_channel) (void) = NULL;
@@ -203,9 +204,19 @@
 	 * LOCK THIS CODE REGION
 	 */
 
+	repeat = 5;
+again:
 	rv = SYS_MutexTryLock(rContext->mMutex);
 	if (EBUSY == rv)
+	{
 		Log1(PCSC_LOG_ERROR, "Locking failed");
+		repeat--;
+		if (repeat)
+		{
+			SYS_USleep(100*1000);	/* 100 ms */
+			goto again;
+		}
+	}
 #ifndef PCSCLITE_STATIC_DRIVER
 	if (rContext->dwVersion == IFD_HVERSION_1_0)
 




More information about the Pcsclite-cvs-commit mailing list