[Pcsclite-cvs-commit] r6360 - /trunk/PCSC/src/winscard_clnt.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Jun 26 14:11:59 UTC 2012
Author: rousseau
Date: Tue Jun 26 14:11:58 2012
New Revision: 6360
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6360
Log:
Similar patch as in revision 6358 but for SCardBeginTransaction()
Thanks to Aleksey Samsonov for the patch
http://archives.neohapsis.com/archives/dev/muscle/2012-q2/0109.html
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=6360&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue Jun 26 14:11:58 2012
@@ -1160,33 +1160,33 @@
if (rv == -1)
return SCARD_E_INVALID_HANDLE;
- (void)pthread_mutex_lock(currentContextMap->mMutex);
-
- /* check the handle is still valid */
- rv = SCardGetContextAndChannelFromHandle(hCard, ¤tContextMap,
- &pChannelMap);
- if (rv == -1)
- /* the handle is now invalid
- * -> another thread may have called SCardReleaseContext
- * -> so the mMutex has been unlocked */
- return SCARD_E_INVALID_HANDLE;
-
- scBeginStruct.hCard = hCard;
- scBeginStruct.rv = SCARD_S_SUCCESS;
-
/*
* Query the server every so often until the sharing violation ends
* and then hold the lock for yourself.
*/
- do
- {
+ for(;;)
+ {
+ (void)pthread_mutex_lock(currentContextMap->mMutex);
+
+ /* check the handle is still valid */
+ rv = SCardGetContextAndChannelFromHandle(hCard, ¤tContextMap,
+ &pChannelMap);
+ if (rv == -1)
+ /* the handle is now invalid
+ * -> another thread may have called SCardReleaseContext
+ * -> so the mMutex has been unlocked */
+ return SCARD_E_INVALID_HANDLE;
+
+ scBeginStruct.hCard = hCard;
+ scBeginStruct.rv = SCARD_S_SUCCESS;
+
rv = MessageSendWithHeader(SCARD_BEGIN_TRANSACTION,
currentContextMap->dwClientID,
sizeof(scBeginStruct), (void *) &scBeginStruct);
if (rv != SCARD_S_SUCCESS)
- goto end;
+ break;
/*
* Read a message from the server
@@ -1195,13 +1195,18 @@
currentContextMap->dwClientID);
if (rv != SCARD_S_SUCCESS)
- goto end;
+ break;
rv = scBeginStruct.rv;
+
+ if (SCARD_E_SHARING_VIOLATION != rv)
+ break;
+
+ (void)pthread_mutex_unlock(currentContextMap->mMutex);
+ (void)SYS_USleep(PCSCLITE_LOCK_POLL_RATE);
}
while (SCARD_E_SHARING_VIOLATION == rv);
-end:
(void)pthread_mutex_unlock(currentContextMap->mMutex);
PROFILE_END(rv)
More information about the Pcsclite-cvs-commit
mailing list