diff options
author | Marcus Brinkmann <[email protected]> | 2012-01-03 21:12:37 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2012-01-25 13:50:47 +0000 |
commit | 7a7a59782766a8bde0c3e7156d14bb2b0e4a3951 (patch) | |
tree | 9a22b6f581fe07e990014d860a2647b4df54d33a /g13/runner.c | |
parent | Require gitlog-to-changelog to be installed. (diff) | |
download | gnupg-7a7a59782766a8bde0c3e7156d14bb2b0e4a3951.tar.gz gnupg-7a7a59782766a8bde0c3e7156d14bb2b0e4a3951.zip |
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.
Diffstat (limited to 'g13/runner.c')
-rw-r--r-- | g13/runner.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/g13/runner.c b/g13/runner.c index 7e9c262c3..7680d3d5b 100644 --- a/g13/runner.c +++ b/g13/runner.c @@ -24,7 +24,7 @@ #include <errno.h> #include <unistd.h> #include <assert.h> -#include <pth.h> +#include <npth.h> #include "g13.h" #include "i18n.h" @@ -40,7 +40,7 @@ struct runner_s unsigned int identifier; /* The runner identifier. */ int spawned; /* True if runner_spawn has been called. */ - pth_t threadid; /* The TID of the runner thread. */ + npth_t thread; /* The TID of the runner thread. */ runner_t next_running; /* Builds a list of all running threads. */ int canceled; /* Set if a cancel has already been send once. */ @@ -85,7 +85,7 @@ writen (int fd, const void *buf, size_t nbytes) while (nleft > 0) { - nwritten = pth_write (fd, buf, nleft); + nwritten = npth_write (fd, buf, nleft); if (nwritten < 0) { if (errno == EINTR) @@ -408,8 +408,9 @@ gpg_error_t runner_spawn (runner_t runner) { gpg_error_t err; - pth_attr_t tattr; - pth_t tid; + npth_attr_t tattr; + npth_t thread; + int ret; if (check_already_spawned (runner, "runner_spawn")) return gpg_error (GPG_ERR_BUG); @@ -433,26 +434,26 @@ runner_spawn (runner_t runner) runner->in_fd = -1; /* Now owned by status_fp. */ } - tattr = pth_attr_new (); - pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); - pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 128*1024); - pth_attr_set (tattr, PTH_ATTR_NAME, runner->name); + npth_attr_init (&tattr); + npth_attr_setdetachstate (&tattr, NPTH_CREATE_DETACHED); - tid = pth_spawn (tattr, runner_thread, runner); - if (!tid) + ret = npth_create (&thread, &tattr, runner_thread, runner); + if (ret) { - err = gpg_error_from_syserror (); + err = gpg_error_from_errno (ret); log_error ("error spawning runner thread: %s\n", gpg_strerror (err)); return err; } + npth_setname_np (thread, runner->name); + /* The scheduler has not yet kicked in, thus we can safely set the spawned flag and the tid. */ runner->spawned = 1; - runner->threadid = tid; + runner->thread = thread; runner->next_running = running_threads; running_threads = runner; - pth_attr_destroy (tattr); + npth_attr_destroy (&tattr); /* The runner thread is now runnable. */ |