mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
scd: Serialize opening device by select_application.
* scd/app.c (app_new_register): Don't lock APP_LIST_LOCK here. (select_application): Lock with APP_LIST_LOCK earlier. -- What we want to do here is to serialize the call of select_application. In the old code, it was possible that a call of select_application was blocked internally, and then another call of select_application entered. We can have a dedicated lock for call of select_application, but it is easier to re-use APP_LIST_LOCK. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
483e63f9b5
commit
47106ac435
@ -299,11 +299,8 @@ app_new_register (int slot, ctrl_t ctrl, const char *name,
|
||||
}
|
||||
|
||||
app->periodical_check_needed = periodical_check_needed;
|
||||
|
||||
npth_mutex_lock (&app_list_lock);
|
||||
app->next = app_top;
|
||||
app_top = app;
|
||||
npth_mutex_unlock (&app_list_lock);
|
||||
unlock_app (app);
|
||||
return 0;
|
||||
}
|
||||
@ -322,6 +319,8 @@ select_application (ctrl_t ctrl, const char *name, app_t *r_app,
|
||||
|
||||
*r_app = NULL;
|
||||
|
||||
npth_mutex_lock (&app_list_lock);
|
||||
|
||||
if (scan || !app_top)
|
||||
{
|
||||
struct dev_list *l;
|
||||
@ -330,7 +329,10 @@ select_application (ctrl_t ctrl, const char *name, app_t *r_app,
|
||||
/* Scan the devices to find new device(s). */
|
||||
err = apdu_dev_list_start (opt.reader_port, &l);
|
||||
if (err)
|
||||
{
|
||||
npth_mutex_unlock (&app_list_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -365,7 +367,6 @@ select_application (ctrl_t ctrl, const char *name, app_t *r_app,
|
||||
scd_kick_the_loop ();
|
||||
}
|
||||
|
||||
npth_mutex_lock (&app_list_lock);
|
||||
for (a = app_top; a; a = a->next)
|
||||
{
|
||||
lock_app (a, ctrl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user