[Pcsclite-cvs-commit] r4807 - in /trunk/PCSC/src: readerfactory.c readerfactory.h
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Mar 9 15:19:05 UTC 2010
Author: rousseau
Date: Tue Mar 9 15:19:05 2010
New Revision: 4807
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4807
Log:
manipulations of handlesList field of ReaderContext should now be thread safe
Modified:
trunk/PCSC/src/readerfactory.c
trunk/PCSC/src/readerfactory.h
Modified: trunk/PCSC/src/readerfactory.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/readerfactory.c?rev=4807&op=diff
==============================================================================
--- trunk/PCSC/src/readerfactory.c (original)
+++ trunk/PCSC/src/readerfactory.c Tue Mar 9 15:19:05 2010
@@ -190,6 +190,8 @@
"list_attributes_seeker failed with return value: %X", lrv);
return SCARD_E_NO_MEMORY;
}
+
+ (void)SYS_MutexInit(&(sReadersContexts[dwContext])->handlesList_lock);
/* If a clone to this reader exists take some values from that clone */
if (parentNode >= 0 && parentNode < PCSCLITE_MAX_READERS_CONTEXTS)
@@ -378,6 +380,8 @@
return SCARD_E_NO_MEMORY;
}
+ (void)SYS_MutexInit(&(sReadersContexts[dwContextB])->handlesList_lock);
+
/* Call on the parent driver to see if the slots are thread safe */
dwGetSize = sizeof(ucThread);
rv = IFDGetCapabilities((sReadersContexts[dwContext]),
@@ -490,6 +494,7 @@
sContext->dwIdentity = 0;
sContext->readerState = NULL;
+ (void)SYS_MutexLock(&sContext->handlesList_lock);
while (list_size(&(sContext->handlesList)) != 0)
{
int lrv;
@@ -503,6 +508,7 @@
free(currentHandle);
}
+ (void)SYS_MutexUnLock(&sContext->handlesList_lock);
list_destroy(&(sContext->handlesList));
dwNumReadersContexts -= 1;
@@ -1050,6 +1056,7 @@
RDR_CLIHANDLES *currentHandle;
list_t * l = &((sReadersContexts[i])->handlesList);
+ (void)SYS_MutexLock(&(sReadersContexts[i])->handlesList_lock);
list_iterator_start(l);
while (list_iterator_hasnext(l))
{
@@ -1060,10 +1067,12 @@
/* Get a new handle and loop again */
randHandle = SYS_RandomInt(10, 65000);
list_iterator_stop(l);
+ (void)SYS_MutexUnLock(&(sReadersContexts[i])->handlesList_lock);
goto again;
}
}
list_iterator_stop(l);
+ (void)SYS_MutexUnLock(&(sReadersContexts[i])->handlesList_lock);
}
}
@@ -1123,7 +1132,9 @@
newHandle->hCard = hCard;
newHandle->dwEventStatus = 0;
+ (void)SYS_MutexLock(&rContext->handlesList_lock);
lrv = list_append(&(rContext->handlesList), newHandle);
+ (void)SYS_MutexUnLock(&rContext->handlesList_lock);
if (lrv < 0)
{
free(newHandle);
@@ -1146,7 +1157,9 @@
return SCARD_E_INVALID_HANDLE;
}
+ (void)SYS_MutexLock(&rContext->handlesList_lock);
lrv = list_delete(&(rContext->handlesList), currentHandle);
+ (void)SYS_MutexUnLock(&rContext->handlesList_lock);
if (lrv < 0)
Log2(PCSC_LOG_CRITICAL,
"list_delete failed with return value: %X", lrv);
Modified: trunk/PCSC/src/readerfactory.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/readerfactory.h?rev=4807&op=diff
==============================================================================
--- trunk/PCSC/src/readerfactory.h (original)
+++ trunk/PCSC/src/readerfactory.h Tue Mar 9 15:19:05 2010
@@ -112,6 +112,7 @@
RESPONSECODE (*pthCardEvent)(DWORD); /**< Card Event sync */
PCSCLITE_MUTEX *mMutex; /**< Mutex for this connection */
list_t handlesList;
+ PCSCLITE_MUTEX handlesList_lock; /**< lock for the above list */
/**< Structure of connected handles */
union
{
More information about the Pcsclite-cvs-commit
mailing list