mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Port to npth.
* configure.ac: Don't check for PTH but for NPTH. (AH_BOTTOM): Remove PTH_SYSCALL_SOFT. (have_pth): Rename to ... (have_npth): ... this. (USE_GNU_NPTH): Rename to ... (USE_GNU_PTH): ... this. * m4/npth.m4: New file. * agent/Makefile.am, agent/cache.c, agent/call-pinentry.c, agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c, agent/trustlist.c, common/Makefile.am, common/estream.c, common/exechelp-posix.c, common/exechelp-w32.c, common/exechelp-w32ce.c, common/http.c, common/init.c, common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c, dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c, dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am, g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am, scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c, scd/scdaemon.c, tools/Makefile.am: Port to npth.
This commit is contained in:
parent
495dc68586
commit
7a7a597827
36 changed files with 969 additions and 1098 deletions
49
scd/app.c
49
scd/app.c
|
@ -22,7 +22,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pth.h>
|
||||
#include <npth.h>
|
||||
|
||||
#include "scdaemon.h"
|
||||
#include "app-common.h"
|
||||
|
@ -37,7 +37,7 @@
|
|||
static struct
|
||||
{
|
||||
int initialized;
|
||||
pth_mutex_t lock;
|
||||
npth_mutex_t lock;
|
||||
app_t app; /* Application context in use or NULL. */
|
||||
app_t last_app; /* Last application object used as this slot or NULL. */
|
||||
} lock_table[10];
|
||||
|
@ -72,30 +72,30 @@ print_progress_line (void *opaque, const char *what, int pc, int cur, int tot)
|
|||
static gpg_error_t
|
||||
lock_reader (int slot, ctrl_t ctrl)
|
||||
{
|
||||
gpg_error_t err;
|
||||
int res;
|
||||
|
||||
if (slot < 0 || slot >= DIM (lock_table))
|
||||
return gpg_error (slot<0? GPG_ERR_INV_VALUE : GPG_ERR_RESOURCE_LIMIT);
|
||||
|
||||
if (!lock_table[slot].initialized)
|
||||
{
|
||||
if (!pth_mutex_init (&lock_table[slot].lock))
|
||||
res = npth_mutex_init (&lock_table[slot].lock, NULL);
|
||||
if (res)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
log_error ("error initializing mutex: %s\n", strerror (errno));
|
||||
return err;
|
||||
log_error ("error initializing mutex: %s\n", strerror (res));
|
||||
return gpg_error_from_errno (res);
|
||||
}
|
||||
lock_table[slot].initialized = 1;
|
||||
lock_table[slot].app = NULL;
|
||||
lock_table[slot].last_app = NULL;
|
||||
}
|
||||
|
||||
if (!pth_mutex_acquire (&lock_table[slot].lock, 0, NULL))
|
||||
res = npth_mutex_lock (&lock_table[slot].lock);
|
||||
if (res)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
log_error ("failed to acquire APP lock for slot %d: %s\n",
|
||||
slot, strerror (errno));
|
||||
return err;
|
||||
slot, strerror (res));
|
||||
return gpg_error_from_errno (res);
|
||||
}
|
||||
|
||||
apdu_set_progress_cb (slot, print_progress_line, ctrl);
|
||||
|
@ -107,32 +107,18 @@ lock_reader (int slot, ctrl_t ctrl)
|
|||
static void
|
||||
unlock_reader (int slot)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (slot < 0 || slot >= DIM (lock_table)
|
||||
|| !lock_table[slot].initialized)
|
||||
log_bug ("unlock_reader called for invalid slot %d\n", slot);
|
||||
|
||||
apdu_set_progress_cb (slot, NULL, NULL);
|
||||
|
||||
if (!pth_mutex_release (&lock_table[slot].lock))
|
||||
res = npth_mutex_unlock (&lock_table[slot].lock);
|
||||
if (res)
|
||||
log_error ("failed to release APP lock for slot %d: %s\n",
|
||||
slot, strerror (errno));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dump_mutex_state (pth_mutex_t *m)
|
||||
{
|
||||
#ifdef _W32_PTH_H
|
||||
(void)m;
|
||||
log_printf ("unknown under W32");
|
||||
#else
|
||||
if (!(m->mx_state & PTH_MUTEX_INITIALIZED))
|
||||
log_printf ("not_initialized");
|
||||
else if (!(m->mx_state & PTH_MUTEX_LOCKED))
|
||||
log_printf ("not_locked");
|
||||
else
|
||||
log_printf ("locked tid=0x%lx count=%lu", (long)m->mx_owner, m->mx_count);
|
||||
#endif
|
||||
slot, strerror (res));
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,8 +132,7 @@ app_dump_state (void)
|
|||
for (slot=0; slot < DIM (lock_table); slot++)
|
||||
if (lock_table[slot].initialized)
|
||||
{
|
||||
log_info ("app_dump_state: slot=%d lock=", slot);
|
||||
dump_mutex_state (&lock_table[slot].lock);
|
||||
log_info ("app_dump_state: slot=%d", slot);
|
||||
if (lock_table[slot].app)
|
||||
{
|
||||
log_printf (" app=%p", lock_table[slot].app);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue