[Pcsclite-cvs-commit] r4805 - /trunk/PCSC/src/winscard_svc.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Mar 9 15:08:15 UTC 2010
Author: rousseau
Date: Tue Mar 9 15:07:55 2010
New Revision: 4805
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4805
Log:
manipulations of cardsList should now be thread safe
Modified:
trunk/PCSC/src/winscard_svc.c
Modified: trunk/PCSC/src/winscard_svc.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_svc.c?rev=4805&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_svc.c (original)
+++ trunk/PCSC/src/winscard_svc.c Tue Mar 9 15:07:55 2010
@@ -59,6 +59,7 @@
{
int32_t hContext;
list_t cardsList;
+ PCSCLITE_MUTEX cardsList_lock; /**< lock for the above list */
uint32_t dwClientID; /**< Connection ID used to reference the Client. */
PCSCLITE_THREAD_T pthThread; /**< Event polling thread's ID */
int protocol_major, protocol_minor; /**< Protocol number agreed between client and server*/
@@ -185,6 +186,8 @@
list_destroy(&(newContext->cardsList));
goto error;
}
+
+ (void)SYS_MutexInit(&newContext->cardsList_lock);
(void)SYS_MutexLock(&contextsList_lock);
lrv = list_append(&contextsList, newContext);
@@ -784,6 +787,7 @@
if (threadContext->hContext != hContext)
return SCARD_E_INVALID_VALUE;
+ (void)SYS_MutexLock(&threadContext->cardsList_lock);
while (list_size(&(threadContext->cardsList)) != 0)
{
READER_CONTEXT * rContext = NULL;
@@ -806,7 +810,10 @@
*/
rv = RFReaderInfoById(hCard, &rContext);
if (rv != SCARD_S_SUCCESS)
+ {
+ (void)SYS_MutexUnLock(&threadContext->cardsList_lock);
return rv;
+ }
hLockId = rContext->hLockId;
rContext->hLockId = 0;
@@ -840,6 +847,7 @@
Log2(PCSC_LOG_CRITICAL,
"list_delete_at failed with return value: %X", lrv);
}
+ (void)SYS_MutexUnLock(&threadContext->cardsList_lock);
list_destroy(&(threadContext->cardsList));
/* We only mark the context as no longer in use.
@@ -868,7 +876,9 @@
return SCARD_E_NO_MEMORY;
}
+ (void)SYS_MutexLock(&threadContext->cardsList_lock);
lrv = list_append(&(threadContext->cardsList), &hCard);
+ (void)SYS_MutexUnLock(&threadContext->cardsList_lock);
if (lrv < 0)
{
Log2(PCSC_LOG_CRITICAL, "list_append failed with return value: %X",
@@ -885,7 +895,9 @@
{
int lrv;
+ (void)SYS_MutexLock(&threadContext->cardsList_lock);
lrv = list_delete(&(threadContext->cardsList), &hCard);
+ (void)SYS_MutexUnLock(&threadContext->cardsList_lock);
if (lrv < 0)
{
Log2(PCSC_LOG_CRITICAL, "list_delete failed with error %X", lrv);
@@ -899,7 +911,9 @@
static LONG MSGCheckHandleAssociation(SCARDHANDLE hCard, SCONTEXT * threadContext)
{
int list_index = 0;
+ (void)SYS_MutexLock(&threadContext->cardsList_lock);
list_index = list_locate(&(threadContext->cardsList), &hCard);
+ (void)SYS_MutexUnLock(&threadContext->cardsList_lock);
if (list_index >= 0)
return 0;
More information about the Pcsclite-cvs-commit
mailing list