diff options
author | Marcus Brinkmann <[email protected]> | 2012-01-03 21:12:37 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2012-01-25 13:07:08 +0000 |
commit | e917c07b2664bb01a5f7b5975723b90da0f396c9 (patch) | |
tree | e31e737fe07e96b596f8bbbaf16a1e122ac683ae /scd/command.c | |
parent | Require gitlog-to-changelog to be installed. (diff) | |
download | gnupg-npth-3.tar.gz gnupg-npth-3.zip |
Port to npth.npth-3
* 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.
Diffstat (limited to 'scd/command.c')
-rw-r--r-- | scd/command.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/scd/command.c b/scd/command.c index 88f8ec2c9..4c3646c99 100644 --- a/scd/command.c +++ b/scd/command.c @@ -26,8 +26,8 @@ #include <ctype.h> #include <unistd.h> #include <signal.h> -#ifdef USE_GNU_PTH -# include <pth.h> +#ifdef USE_NPTH +# include <npth.h> #endif #include "scdaemon.h" @@ -156,7 +156,7 @@ static struct server_local_s *locked_session; /* While doing a reset we need to make sure that the ticker does not call scd_update_reader_status_file while we are using it. */ -static pth_mutex_t status_file_update_lock; +static npth_mutex_t status_file_update_lock; /*-- Local prototypes --*/ @@ -173,10 +173,12 @@ void initialize_module_command (void) { static int initialized; + int err; if (!initialized) { - if (pth_mutex_init (&status_file_update_lock)) + err = npth_mutex_init (&status_file_update_lock, NULL); + if (!err) initialized = 1; } } @@ -304,6 +306,7 @@ do_reset (ctrl_t ctrl, int send_reset) { int vrdr = ctrl->server_local->vreader_idx; int slot; + int err; if (!(vrdr == -1 || (vrdr >= 0 && vrdr < DIM(vreader_table)))) BUG (); @@ -360,7 +363,8 @@ do_reset (ctrl_t ctrl, int send_reset) try to update the file. Calling update_reader_status_file is required to get hold of the new status of the card in the vreader table. */ - if (!pth_mutex_acquire (&status_file_update_lock, 0, NULL)) + err = npth_mutex_lock (&status_file_update_lock); + if (err) { log_error ("failed to acquire status_file_update lock\n"); ctrl->server_local->vreader_idx = -1; @@ -368,8 +372,10 @@ do_reset (ctrl_t ctrl, int send_reset) } update_reader_status_file (0); /* Update slot status table. */ update_card_removed (vrdr, 0); /* Clear card_removed flag. */ - if (!pth_mutex_release (&status_file_update_lock)) - log_error ("failed to release status_file_update lock\n"); + err = npth_mutex_unlock (&status_file_update_lock); + if (err) + log_error ("failed to release status_file_update lock: %s\n", + strerror (err)); /* Do this last, so that the update_card_removed above does its job. */ ctrl->server_local->vreader_idx = -1; @@ -1597,18 +1603,18 @@ cmd_lock (assuan_context_t ctx, char *line) else locked_session = ctrl->server_local; -#ifdef USE_GNU_PTH +#ifdef USE_NPTH if (rc && has_option (line, "--wait")) { rc = 0; - pth_sleep (1); /* Better implement an event mechanism. However, - for card operations this should be - sufficient. */ + npth_sleep (1); /* Better implement an event mechanism. However, + for card operations this should be + sufficient. */ /* FIXME: Need to check that the connection is still alive. This can be done by issuing status messages. */ goto retry; } -#endif /*USE_GNU_PTH*/ +#endif /*USE_NPTH*/ if (rc) log_error ("cmd_lock failed: %s\n", gpg_strerror (rc)); @@ -2395,9 +2401,13 @@ update_reader_status_file (int set_card_removed_flag) void scd_update_reader_status_file (void) { - if (!pth_mutex_acquire (&status_file_update_lock, 1, NULL)) + int err; + err = npth_mutex_lock (&status_file_update_lock); + if (err) return; /* locked - give up. */ update_reader_status_file (1); - if (!pth_mutex_release (&status_file_update_lock)) - log_error ("failed to release status_file_update lock\n"); + err = npth_mutex_unlock (&status_file_update_lock); + if (err) + log_error ("failed to release status_file_update lock: %s\n", + strerror (err)); } |