Changeset View
Changeset View
Standalone View
Standalone View
scd/apdu.c
Context not available. | |||||
} | } | ||||
static void | |||||
release_pcsc_context (void) | |||||
{ | |||||
/*log_debug ("%s: releasing context\n", __func__);*/ | |||||
pcsc_release_context (pcsc.context); | |||||
pcsc.context = 0; | |||||
} | |||||
static int | static int | ||||
close_pcsc_reader (int slot) | close_pcsc_reader (int slot) | ||||
{ | { | ||||
/*log_debug ("%s: count=%d (ctx=%x)\n", __func__, pcsc.count, pcsc.context);*/ | /*log_debug ("%s: count=%d (ctx=%x)\n", __func__, pcsc.count, pcsc.context);*/ | ||||
(void)slot; | (void)slot; | ||||
if (!pcsc.count || !--pcsc.count) | if (!--pcsc.count) | ||||
{ | release_pcsc_context (); | ||||
werner: That change re-introduces the original problem. Well, probably not because your other changes… | |||||
gniibeAuthorUnsubmitted Done Inline ActionsAssertions are added. gniibe: Assertions are added.
| |||||
int i; | |||||
/*log_debug ("%s: releasing context\n", __func__);*/ | |||||
if (pcsc.context) | |||||
pcsc_release_context (pcsc.context); | |||||
pcsc.context = 0; | |||||
for (i = 0; i < MAX_READER; i++) | |||||
pcsc.rdrname[i] = NULL; | |||||
} | |||||
return 0; | return 0; | ||||
} | } | ||||
Context not available. | |||||
err = gpg_error_from_syserror (); | err = gpg_error_from_syserror (); | ||||
log_error ("error allocating memory for reader list\n"); | log_error ("error allocating memory for reader list\n"); | ||||
if (pcsc.count == 0) | |||||
release_pcsc_context (); | |||||
npth_mutex_unlock (&reader_table_lock); | npth_mutex_unlock (&reader_table_lock); | ||||
close_pcsc_reader (0); | |||||
xfree (dl); | xfree (dl); | ||||
return err; | return err; | ||||
} | } | ||||
Context not available. | |||||
log_error ("pcsc_list_readers failed: %s (0x%lx)\n", | log_error ("pcsc_list_readers failed: %s (0x%lx)\n", | ||||
pcsc_error_string (r), r); | pcsc_error_string (r), r); | ||||
xfree (p); | xfree (p); | ||||
if (pcsc.count == 0) | |||||
release_pcsc_context (); | |||||
npth_mutex_unlock (&reader_table_lock); | npth_mutex_unlock (&reader_table_lock); | ||||
close_pcsc_reader (0); | |||||
xfree (dl); | xfree (dl); | ||||
return iso7816_map_sw (pcsc_error_to_sw (r)); | return iso7816_map_sw (pcsc_error_to_sw (r)); | ||||
} | } | ||||
Context not available. | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
pcsc.count++; | |||||
} | } | ||||
npth_mutex_unlock (&reader_table_lock); | |||||
*l_p = dl; | *l_p = dl; | ||||
return 0; | return 0; | ||||
} | } | ||||
Context not available. | |||||
else | else | ||||
#endif | #endif | ||||
{ /* PC/SC readers. */ | { /* PC/SC readers. */ | ||||
int i; | |||||
xfree (dl->table); | xfree (dl->table); | ||||
close_pcsc_reader (0); | for (i = 0; i < MAX_READER; i++) | ||||
pcsc.rdrname[i] = NULL; | |||||
if (pcsc.count == 0) | |||||
release_pcsc_context (); | |||||
} | } | ||||
xfree (dl); | xfree (dl); | ||||
npth_mutex_unlock (&reader_table_lock); | |||||
} | } | ||||
Context not available. |
That change re-introduces the original problem. Well, probably not because your other changes take care that the counter is not already at zero. However, this is too easy to get wrong, so a log_assert (pcsc.count > 0) would be appreciated.