Changeset View
Changeset View
Standalone View
Standalone View
scd/apdu.c
Context not available. | |||||
static struct reader_table_s reader_table[MAX_READER]; | static struct reader_table_s reader_table[MAX_READER]; | ||||
#ifdef USE_NPTH | #ifdef USE_NPTH | ||||
static npth_mutex_t reader_table_lock; | npth_mutex_t reader_table_lock; | ||||
#endif | #endif | ||||
werner: That change re-introduces the original problem. Well, probably not because your other changes… | |||||
Done Inline ActionsAssertions are added. gniibe: Assertions are added.
| |||||
Context not available. | |||||
dl->idx = 0; | dl->idx = 0; | ||||
dl->idx_max = 0; | dl->idx_max = 0; | ||||
npth_mutex_lock (&reader_table_lock); | |||||
#ifdef HAVE_LIBUSB | #ifdef HAVE_LIBUSB | ||||
if (!opt.disable_ccid) | if (!opt.disable_ccid) | ||||
{ | { | ||||
Context not available. | |||||
if (err) | if (err) | ||||
{ | { | ||||
xfree (dl); | xfree (dl); | ||||
npth_mutex_unlock (&reader_table_lock); | |||||
return err; | return err; | ||||
} | } | ||||
Context not available. | |||||
log_debug ("leave: apdu_open_reader => slot=-1 (no ccid)\n"); | log_debug ("leave: apdu_open_reader => slot=-1 (no ccid)\n"); | ||||
xfree (dl); | xfree (dl); | ||||
npth_mutex_unlock (&reader_table_lock); | |||||
return gpg_error (GPG_ERR_ENODEV); | return gpg_error (GPG_ERR_ENODEV); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
if (pcsc_init () < 0) | if (pcsc_init () < 0) | ||||
{ | { | ||||
xfree (dl); | xfree (dl); | ||||
npth_mutex_unlock (&reader_table_lock); | |||||
return gpg_error (GPG_ERR_NO_SERVICE); | return gpg_error (GPG_ERR_NO_SERVICE); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
log_error ("error allocating memory for reader list\n"); | log_error ("error allocating memory for reader list\n"); | ||||
if (pcsc.count == 0) | if (pcsc.count == 0) | ||||
release_pcsc_context (); | release_pcsc_context (); | ||||
npth_mutex_unlock (&reader_table_lock); | |||||
xfree (dl); | xfree (dl); | ||||
return err; | return err; | ||||
} | } | ||||
Context not available. | |||||
xfree (p); | xfree (p); | ||||
if (pcsc.count == 0) | if (pcsc.count == 0) | ||||
release_pcsc_context (); | release_pcsc_context (); | ||||
npth_mutex_unlock (&reader_table_lock); | |||||
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. | |||||
pcsc.rdrname[i] = NULL; | pcsc.rdrname[i] = NULL; | ||||
log_assert (pcsc.count > 0); | log_assert (pcsc.count > 0); | ||||
if (--pcsc.count == 0) | if (pcsc.count == 0) | ||||
release_pcsc_context (); | 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.