mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +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
29
g13/runner.c
29
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. */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue