[Pcsclite-git-commit] [PCSC] 05/06: Client side: SCardGetAndLockContext() always locks
Ludovic Rousseau
rousseau at moszumanska.debian.org
Fri Jan 27 20:40:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
rousseau pushed a commit to branch master
in repository PCSC.
commit 8193d6fad84539af03a329e0f6911125f96497d0
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date: Fri Jan 27 10:43:35 2017 +0100
Client side: SCardGetAndLockContext() always locks
SCardGetAndLockContext() has the lock parameter removed and now always
lock.
From Maksim Ivanov:
Also it may be advisable to change the SCardGetAndLockContext
function interface so that it's more difficult to use it in thread-unsafe
manner: remove the second parameter "int lock" and make the
locking behavior the default one, and introduce another function
that does no locks and returns a boolean instead of an
SCONTEXTMAP* pointer.
Thanks to Maksim Ivanov for the proposal
"[Pcsclite-muscle] Data races related to SCardCancel"
http://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20170116/000789.html
---
src/winscard_clnt.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/winscard_clnt.c b/src/winscard_clnt.c
index a638642..beaefeb 100644
--- a/src/winscard_clnt.c
+++ b/src/winscard_clnt.c
@@ -367,7 +367,7 @@ PCSC_API const SCARD_IO_REQUEST g_rgSCardRawPci = { SCARD_PROTOCOL_RAW, sizeof(S
static LONG SCardAddContext(SCARDCONTEXT, DWORD);
-static SCONTEXTMAP * SCardGetAndLockContext(SCARDCONTEXT, int);
+static SCONTEXTMAP * SCardGetAndLockContext(SCARDCONTEXT);
static SCONTEXTMAP * SCardGetContextTH(SCARDCONTEXT);
static LONG SCardRemoveContext(SCARDCONTEXT);
static LONG SCardCleanContext(SCONTEXTMAP *);
@@ -680,7 +680,7 @@ LONG SCardReleaseContext(SCARDCONTEXT hContext)
* Make sure this context has been opened
* and get currentContextMap
*/
- currentContextMap = SCardGetAndLockContext(hContext, TRUE);
+ currentContextMap = SCardGetAndLockContext(hContext);
if (NULL == currentContextMap)
{
rv = SCARD_E_INVALID_HANDLE;
@@ -810,7 +810,7 @@ LONG SCardConnect(SCARDCONTEXT hContext, LPCSTR szReader,
/*
* Make sure this context has been opened
*/
- currentContextMap = SCardGetAndLockContext(hContext, TRUE);
+ currentContextMap = SCardGetAndLockContext(hContext);
if (NULL == currentContextMap)
return SCARD_E_INVALID_HANDLE;
@@ -1718,7 +1718,7 @@ LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout,
/*
* Make sure this context has been opened
*/
- currentContextMap = SCardGetAndLockContext(hContext, TRUE);
+ currentContextMap = SCardGetAndLockContext(hContext);
if (NULL == currentContextMap)
{
rv = SCARD_E_INVALID_HANDLE;
@@ -2831,7 +2831,7 @@ LONG SCardListReaders(SCARDCONTEXT hContext, /*@unused@*/ LPCSTR mszGroups,
/*
* Make sure this context has been opened
*/
- currentContextMap = SCardGetAndLockContext(hContext, TRUE);
+ currentContextMap = SCardGetAndLockContext(hContext);
if (NULL == currentContextMap)
{
PROFILE_END(SCARD_E_INVALID_HANDLE)
@@ -3011,7 +3011,7 @@ LONG SCardListReaderGroups(SCARDCONTEXT hContext, LPSTR mszGroups,
/*
* Make sure this context has been opened
*/
- currentContextMap = SCardGetAndLockContext(hContext, TRUE);
+ currentContextMap = SCardGetAndLockContext(hContext);
if (NULL == currentContextMap)
return SCARD_E_INVALID_HANDLE;
@@ -3098,7 +3098,7 @@ LONG SCardCancel(SCARDCONTEXT hContext)
/*
* Make sure this context has been opened
*/
- currentContextMap = SCardGetAndLockContext(hContext, TRUE);
+ currentContextMap = SCardGetAndLockContext(hContext);
if (NULL == currentContextMap)
{
rv = SCARD_E_INVALID_HANDLE;
@@ -3269,12 +3269,11 @@ error:
* SCardGetContextTH().
*
* @param[in] hContext Application Context whose index will be find.
- * @param[in] lock if TRUE then the context (if available)
*
* @return Index corresponding to the Application Context or -1 if it is
* not found.
*/
-static SCONTEXTMAP * SCardGetAndLockContext(SCARDCONTEXT hContext, int lock)
+static SCONTEXTMAP * SCardGetAndLockContext(SCARDCONTEXT hContext)
{
SCONTEXTMAP * currentContextMap;
@@ -3282,7 +3281,7 @@ static SCONTEXTMAP * SCardGetAndLockContext(SCARDCONTEXT hContext, int lock)
currentContextMap = SCardGetContextTH(hContext);
/* lock the context (if available) */
- if (lock && NULL != currentContextMap)
+ if (NULL != currentContextMap)
(void)pthread_mutex_lock(¤tContextMap->mMutex);
(void)SCardUnlockThread();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/PCSC.git
More information about the Pcsclite-cvs-commit
mailing list