scd: Fix closing reader and reeleasing context in PC/SC.

* scd/apdu.c (close_pcsc_reader): Unlock the reader_table_lock.
(apdu_dev_list_finish): Release the context when no readers.

--

Fixes-commit: 46d185f603
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-07-17 20:42:38 +09:00
parent f484ac2b2d
commit daa2cec6a5
1 changed files with 7 additions and 0 deletions

View File

@ -821,6 +821,7 @@ close_pcsc_reader (int slot)
pcsc.context = 0;
for (i = 0; i < MAX_READER; i++)
pcsc.rdrname[i] = NULL;
npth_mutex_unlock (&reader_table_lock);
}
return 0;
}
@ -2061,6 +2062,12 @@ apdu_dev_list_finish (struct dev_list *dl)
xfree (dl->table);
for (i = 0; i < MAX_READER; i++)
pcsc.rdrname[i] = NULL;
if (pcsc.count == 0)
{
pcsc_release_context (pcsc.context);
pcsc.context = 0;
}
}
xfree (dl);
npth_mutex_unlock (&reader_table_lock);