mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-20 14:37:08 +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;
|
app->periodical_check_needed = periodical_check_needed;
|
||||||
|
|
||||||
npth_mutex_lock (&app_list_lock);
|
|
||||||
app->next = app_top;
|
app->next = app_top;
|
||||||
app_top = app;
|
app_top = app;
|
||||||
npth_mutex_unlock (&app_list_lock);
|
|
||||||
unlock_app (app);
|
unlock_app (app);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -322,6 +319,8 @@ select_application (ctrl_t ctrl, const char *name, app_t *r_app,
|
|||||||
|
|
||||||
*r_app = NULL;
|
*r_app = NULL;
|
||||||
|
|
||||||
|
npth_mutex_lock (&app_list_lock);
|
||||||
|
|
||||||
if (scan || !app_top)
|
if (scan || !app_top)
|
||||||
{
|
{
|
||||||
struct dev_list *l;
|
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). */
|
/* Scan the devices to find new device(s). */
|
||||||
err = apdu_dev_list_start (opt.reader_port, &l);
|
err = apdu_dev_list_start (opt.reader_port, &l);
|
||||||
if (err)
|
if (err)
|
||||||
|
{
|
||||||
|
npth_mutex_unlock (&app_list_lock);
|
||||||
return err;
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -365,7 +367,6 @@ select_application (ctrl_t ctrl, const char *name, app_t *r_app,
|
|||||||
scd_kick_the_loop ();
|
scd_kick_the_loop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
npth_mutex_lock (&app_list_lock);
|
|
||||||
for (a = app_top; a; a = a->next)
|
for (a = app_top; a; a = a->next)
|
||||||
{
|
{
|
||||||
lock_app (a, ctrl);
|
lock_app (a, ctrl);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user