Skip to content

Commit

Permalink
fix SCardCancel() that was broken in version 1.8.21
Browse files Browse the repository at this point in the history
Changes in 9a21c82 broke
SCardCancel().
The problem was that SCardCancel() was blocked until
SCardGetStatusChange() had finished. This is stupid because
SCardCancel() is supposed to cancel SCardGetStatusChange().

Thanks to Ran Benita for the bug report
"[Pcsclite-muscle] A recent change causes SCardCancel() to block?"
http://lists.alioth.debian.org/pipermail/pcsclite-muscle/2017-June/000921.html
  • Loading branch information
LudovicRousseau committed Jun 15, 2017
1 parent 88a53f3 commit 7a3738d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/winscard_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3118,15 +3118,17 @@ LONG SCardCancel(SCARDCONTEXT hContext)
/*
* Make sure this context has been opened
*/
currentContextMap = SCardGetAndLockContext(hContext);
(void)SCardLockThread();
currentContextMap = SCardGetContextTH(hContext);

if (NULL == currentContextMap)
{
(void)SCardUnlockThread();
rv = SCARD_E_INVALID_HANDLE;
goto error;
}

cancellable = currentContextMap->cancellable;
(void)pthread_mutex_unlock(&currentContextMap->mMutex);
(void)SCardUnlockThread();

if (! cancellable)
{
Expand Down

1 comment on commit 7a3738d

@llogar
Copy link

@llogar llogar commented on 7a3738d Sep 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
At least strongSwan still hangs on exit due to SCardCancel() not terminating SCardGetStatusChange() call. I've created pull request #24 with a patch that appears to fix this...

Please sign in to comment.