Threading: Reader locking can fail as well

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2878 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
martin 2006-03-24 08:06:19 +00:00
parent 8be396fee3
commit 1180345d75
1 changed files with 8 additions and 3 deletions

View File

@ -278,7 +278,7 @@ int sc_reset(sc_card_t *card)
int sc_lock(sc_card_t *card)
{
int r = 0;
int r = 0, r2 = 0;
if (card == NULL)
return SC_ERROR_INVALID_ARGUMENTS;
@ -294,7 +294,11 @@ int sc_lock(sc_card_t *card)
}
if (r == 0)
card->lock_count++;
r = sc_mutex_unlock(card->ctx, card->mutex);
r2 = sc_mutex_unlock(card->ctx, card->mutex);
if (r2 != SC_SUCCESS) {
sc_error(card->ctx, "unable to release lock\n");
r = r != SC_SUCCESS ? r : r2;
}
return r;
}
@ -313,7 +317,8 @@ int sc_unlock(sc_card_t *card)
memset(&card->cache, 0, sizeof(card->cache));
card->cache_valid = 0;
if (card->ops->logout != NULL) {
/*XXX*/
/* XXX As this logout causes random asserts on card->lock_count >=0
on card removal under firefox 1.5 */
r = sc_mutex_unlock(card->ctx, card->mutex);
if (r != SC_SUCCESS) {
sc_error(card->ctx, "unable to release lock\n");