mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
scd: move lock_slot, trylock_slot, unlock_slot functions.
* scd/apdu.c (lock_slot, trylock_slot, unlock_slot): Move. -- This is for upcoming changes.
This commit is contained in:
parent
8cb0209022
commit
233b5ab1ad
76
scd/apdu.c
76
scd/apdu.c
@ -328,6 +328,44 @@ static int pcsc_keypad_modify (int slot, int class, int ins, int p0, int p1,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
lock_slot (int slot)
|
||||||
|
{
|
||||||
|
#ifdef USE_GNU_PTH
|
||||||
|
if (!pth_mutex_acquire (&reader_table[slot].lock, 0, NULL))
|
||||||
|
{
|
||||||
|
log_error ("failed to acquire apdu lock: %s\n", strerror (errno));
|
||||||
|
return SW_HOST_LOCKING_FAILED;
|
||||||
|
}
|
||||||
|
#endif /*USE_GNU_PTH*/
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
trylock_slot (int slot)
|
||||||
|
{
|
||||||
|
#ifdef USE_GNU_PTH
|
||||||
|
if (!pth_mutex_acquire (&reader_table[slot].lock, TRUE, NULL))
|
||||||
|
{
|
||||||
|
if (errno == EBUSY)
|
||||||
|
return SW_HOST_BUSY;
|
||||||
|
log_error ("failed to acquire apdu lock: %s\n", strerror (errno));
|
||||||
|
return SW_HOST_LOCKING_FAILED;
|
||||||
|
}
|
||||||
|
#endif /*USE_GNU_PTH*/
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unlock_slot (int slot)
|
||||||
|
{
|
||||||
|
#ifdef USE_GNU_PTH
|
||||||
|
if (!pth_mutex_release (&reader_table[slot].lock))
|
||||||
|
log_error ("failed to release apdu lock: %s\n", strerror (errno));
|
||||||
|
#endif /*USE_GNU_PTH*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Find an unused reader slot for PORTSTR and put it into the reader
|
/* Find an unused reader slot for PORTSTR and put it into the reader
|
||||||
table. Return -1 on error or the index into the reader table. */
|
table. Return -1 on error or the index into the reader table. */
|
||||||
static int
|
static int
|
||||||
@ -2728,44 +2766,6 @@ open_rapdu_reader (int portno,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
lock_slot (int slot)
|
|
||||||
{
|
|
||||||
#ifdef USE_GNU_PTH
|
|
||||||
if (!pth_mutex_acquire (&reader_table[slot].lock, 0, NULL))
|
|
||||||
{
|
|
||||||
log_error ("failed to acquire apdu lock: %s\n", strerror (errno));
|
|
||||||
return SW_HOST_LOCKING_FAILED;
|
|
||||||
}
|
|
||||||
#endif /*USE_GNU_PTH*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
trylock_slot (int slot)
|
|
||||||
{
|
|
||||||
#ifdef USE_GNU_PTH
|
|
||||||
if (!pth_mutex_acquire (&reader_table[slot].lock, TRUE, NULL))
|
|
||||||
{
|
|
||||||
if (errno == EBUSY)
|
|
||||||
return SW_HOST_BUSY;
|
|
||||||
log_error ("failed to acquire apdu lock: %s\n", strerror (errno));
|
|
||||||
return SW_HOST_LOCKING_FAILED;
|
|
||||||
}
|
|
||||||
#endif /*USE_GNU_PTH*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
unlock_slot (int slot)
|
|
||||||
{
|
|
||||||
#ifdef USE_GNU_PTH
|
|
||||||
if (!pth_mutex_release (&reader_table[slot].lock))
|
|
||||||
log_error ("failed to release apdu lock: %s\n", strerror (errno));
|
|
||||||
#endif /*USE_GNU_PTH*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Open the reader and return an internal slot number or -1 on
|
/* Open the reader and return an internal slot number or -1 on
|
||||||
error. If PORTSTR is NULL we default to a suitable port (for ctAPI:
|
error. If PORTSTR is NULL we default to a suitable port (for ctAPI:
|
||||||
the first USB reader. For PC/SC the first listed reader). */
|
the first USB reader. For PC/SC the first listed reader). */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user