* configure.ac (AH_BOTTOM): Define EXEEXT_S.

* autogen.sh: Updated --build-w32 feature.

* gpg-agent.c (main):  Remove special Pth initialize.

* w32-pth.c (pth_init): Reverse return values.  Use TRUE and FALSE
constants.
(pth_kill, pth_mutex_acquire, pth_attr_set, pth_join, pth_cancel):
Ditto.

* scdaemon.c (main) [W32]: Remove special Pth initialize..
This commit is contained in:
Werner Koch 2004-12-18 18:53:32 +00:00
parent 3666a2859b
commit 694037f2a5
11 changed files with 147 additions and 105 deletions

View File

@ -1,3 +1,9 @@
2004-12-18 Werner Koch <wk@g10code.com>
* configure.ac (AH_BOTTOM): Define EXEEXT_S.
* autogen.sh: Updated --build-w32 feature.
2004-12-15 Werner Koch <wk@g10code.com> 2004-12-15 Werner Koch <wk@g10code.com>
* Makefile.am (SUBDIRS) [W32]: Do not build in tests/. * Makefile.am (SUBDIRS) [W32]: Do not build in tests/.

View File

@ -1,5 +1,7 @@
2004-12-18 Werner Koch <wk@g10code.com> 2004-12-18 Werner Koch <wk@g10code.com>
* gpg-agent.c (main): Remove special Pth initialize.
* agent.h (map_assuan_err): Define in terms of * agent.h (map_assuan_err): Define in terms of
map_assuan_err_with_source. map_assuan_err_with_source.

View File

@ -179,9 +179,7 @@ static void create_directories (void);
static void handle_connections (int listen_fd); static void handle_connections (int listen_fd);
/* Pth wrapper function definitions. */ /* Pth wrapper function definitions. */
#ifndef HAVE_W32_SYSTEM
GCRY_THREAD_OPTION_PTH_IMPL; GCRY_THREAD_OPTION_PTH_IMPL;
#endif
#endif /*USE_GNU_PTH*/ #endif /*USE_GNU_PTH*/
static void check_for_running_agent (void); static void check_for_running_agent (void);
@ -439,16 +437,12 @@ main (int argc, char **argv )
/* Libgcrypt requires us to register the threading model first. /* Libgcrypt requires us to register the threading model first.
Note that this will also do the pth_init. */ Note that this will also do the pth_init. */
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
# ifdef HAVE_W32_SYSTEM
pth_init ();
# else /*!HAVE_W32_SYSTEM*/
err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth); err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth);
if (err) if (err)
{ {
log_fatal ("can't register GNU Pth with Libgcrypt: %s\n", log_fatal ("can't register GNU Pth with Libgcrypt: %s\n",
gpg_strerror (err)); gpg_strerror (err));
} }
# endif/*!HAVE_W32_SYSTEM*/
#endif /*USE_GNU_PTH*/ #endif /*USE_GNU_PTH*/
/* Check that the libraries are suitable. Do it here because /* Check that the libraries are suitable. Do it here because

View File

@ -40,64 +40,66 @@ MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
DIE=no DIE=no
if [ "$1" = "--build-w32" ]; then # ***** W32 build script *******
# Used to cross-compile for Windows.
if test "$1" = "--build-w32"; then
tmp=`dirname $0`
tsdir=`cd "$tmp"; pwd`
shift shift
target=i386--mingw32 if [ ! -f $tsdir/scripts/config.guess ]; then
if [ ! -f ./config.guess ]; then echo "$tsdir/scripts/config.guess not found" >&2
echo "./config.guess not found" >&2
exit 1
fi
host=`./config.guess`
if ! mingw32 --version >/dev/null; then
echo "We need at least version 0.3 of MingW32/CPD" >&2
exit 1 exit 1
fi fi
build=`$tsdir/scripts/config.guess`
if [ -f config.h ]; then [ -z "$w32root" ] && w32root="$HOME/w32root"
if grep HAVE_DOSISH_SYSTEM config.h | grep undef >/dev/null; then echo "Using $w32root as standard install directory" >&2
# See whether we have the Debian cross compiler package or the
# old mingw32/cpd system
if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then
host=i586-mingw32msvc
crossbindir=/usr/$host/bin
else
host=i386--mingw32
if ! mingw32 --version >/dev/null; then
echo "We need at least version 0.3 of MingW32/CPD" >&2
exit 1
fi
crossbindir=`mingw32 --install-dir`/bin
# Old autoconf version required us to setup the environment
# with the proper tool names.
CC=`mingw32 --get-path gcc`
CPP=`mingw32 --get-path cpp`
AR=`mingw32 --get-path ar`
RANLIB=`mingw32 --get-path ranlib`
export CC CPP AR RANLIB
fi
if [ -f "$tsdir/config.log" ]; then
if ! head $tsdir/config.log | grep "$host" >/dev/null; then
echo "Pease run a 'make distclean' first" >&2 echo "Pease run a 'make distclean' first" >&2
exit 1 exit 1
fi fi
fi fi
crossinstalldir=`mingw32 --install-dir` ./configure --enable-maintainer-mode --prefix=${w32root} \
crossbindir=`mingw32 --get-bindir 2>/dev/null` \ --host=i586-mingw32msvc --build=${build} \
|| crossbindir="$crossinstalldir/bin" --with-gpg-error-prefix=${w32root} \
crossdatadir=`mingw32 --get-datadir 2>/dev/null` \ --with-ksba-prefix=${w32root} \
|| crossdatadir="$crossinstalldir/share" --with-libgcrypt-prefix=${w32root} \
crosslibdir=`mingw32 --get-libdir 2>/dev/null` \ --with-libassuan-prefix=${w32root} \
|| crosslibdir="$crossinstalldir/i386--mingw32/lib" --with-zlib=${w32root} \
crossincdir=`mingw32 --get-includedir 2>/dev/null` \ --with-pth-prefix=${w32root}
|| crossincdir="$crossinstalldir/i386--mingw32/include" rc=$?
CC=`mingw32 --get-path gcc` # Ugly hack to overcome a gettext problem. Someone should look into
CPP=`mingw32 --get-path cpp` # gettext to figure out why the po directory is not ignored as it used
AR=`mingw32 --get-path ar` # to be.
RANLIB=`mingw32 --get-path ranlib` [ $rc = 0 ] && touch $tsdir/po/all
export CC CPP AR RANLIB exit $rc
disable_foo_tests=""
if [ -n "$lib_config_files" ]; then
for i in $lib_config_files; do
j=`echo $i | tr '[a-z-]' '[A-Z_]'`
eval "$j=${crossbindir}/$i"
export $j
disable_foo_tests="$disable_foo_tests --disable-`echo $i| \
sed 's,-config$,,'`-test"
if [ ! -f "${crossbindir}/$i" ]; then
echo "$i not installed for MingW32" >&2
DIE=yes
fi
done
fi
[ $DIE = yes ] && exit 1
./configure --host=${host} --target=${target} ${disable_foo_tests} \
--bindir=${crossbindir} --libdir=${crosslibdir} \
--datadir=${crossdatadir} --includedir=${crossincdir} \
--enable-maintainer-mode $*
exit $?
fi fi
# ***** end W32 build script *******

View File

@ -231,7 +231,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
cr_flags = (CREATE_DEFAULT_ERROR_MODE cr_flags = (CREATE_DEFAULT_ERROR_MODE
| GetPriorityClass (GetCurrentProcess ()) | GetPriorityClass (GetCurrentProcess ())
| CREATE_SUSPENDED); | CREATE_SUSPENDED);
log_debug ("CreateProcess, path=`%s' cmdline=`%s'", pgmname, cmdline); log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline);
if (!CreateProcess (pgmname, /* Program to start. */ if (!CreateProcess (pgmname, /* Program to start. */
cmdline, /* Command line arguments. */ cmdline, /* Command line arguments. */
&sec_attr, /* Process security attributes. */ &sec_attr, /* Process security attributes. */

View File

@ -255,11 +255,13 @@ AH_BOTTOM([
#define EXTSEP_C '.' #define EXTSEP_C '.'
#define DIRSEP_S "\\" #define DIRSEP_S "\\"
#define EXTSEP_S "." #define EXTSEP_S "."
#define EXEEXT_S ".exe"
#else #else
#define DIRSEP_C '/' #define DIRSEP_C '/'
#define EXTSEP_C '.' #define EXTSEP_C '.'
#define DIRSEP_S "/" #define DIRSEP_S "/"
#define EXTSEP_S "." #define EXTSEP_S "."
#define EXEEXT_S ""
#endif #endif
/* This is the same as VERSION, but should be overridden if the /* This is the same as VERSION, but should be overridden if the
@ -283,20 +285,20 @@ AH_BOTTOM([
/* Setup the hardwired names of modules. */ /* Setup the hardwired names of modules. */
#ifndef GNUPG_DEFAULT_AGENT #ifndef GNUPG_DEFAULT_AGENT
#define GNUPG_DEFAULT_AGENT ( GNUPG_BINDIR DIRSEP_S "gpg-agent" ) #define GNUPG_DEFAULT_AGENT ( GNUPG_BINDIR DIRSEP_S "gpg-agent" EXEEXT_S )
#endif #endif
#ifndef GNUPG_DEFAULT_PINENTRY #ifndef GNUPG_DEFAULT_PINENTRY
#define GNUPG_DEFAULT_PINENTRY ( GNUPG_BINDIR DIRSEP_S "pinentry" ) #define GNUPG_DEFAULT_PINENTRY ( GNUPG_BINDIR DIRSEP_S "pinentry" EXEEXT_S )
#endif #endif
#ifndef GNUPG_DEFAULT_SCDAEMON #ifndef GNUPG_DEFAULT_SCDAEMON
#define GNUPG_DEFAULT_SCDAEMON ( GNUPG_BINDIR DIRSEP_S "scdaemon" ) #define GNUPG_DEFAULT_SCDAEMON ( GNUPG_BINDIR DIRSEP_S "scdaemon" EXEEXT_S )
#endif #endif
#ifndef GNUPG_DEFAULT_DIRMNGR #ifndef GNUPG_DEFAULT_DIRMNGR
#define GNUPG_DEFAULT_DIRMNGR ( GNUPG_BINDIR DIRSEP_S "dirmngr" ) #define GNUPG_DEFAULT_DIRMNGR ( GNUPG_BINDIR DIRSEP_S "dirmngr" EXEEXT_S )
#endif #endif
#ifndef GNUPG_DEFAULT_PROTECT_TOOL #ifndef GNUPG_DEFAULT_PROTECT_TOOL
#define GNUPG_DEFAULT_PROTECT_TOOL \ #define GNUPG_DEFAULT_PROTECT_TOOL \
( GNUPG_LIBEXECDIR DIRSEP_S "gpg-protect-tool" ) ( GNUPG_LIBEXECDIR DIRSEP_S "gpg-protect-tool" EXEEXT_S )
#endif #endif

View File

@ -1,3 +1,10 @@
2004-12-18 Werner Koch <wk@g10code.com>
* w32-pth.c (pth_init): Reverse return values. Use TRUE and FALSE
constants.
(pth_kill, pth_mutex_acquire, pth_attr_set, pth_join, pth_cancel):
Ditto.
2004-12-15 Werner Koch <wk@g10code.com> 2004-12-15 Werner Koch <wk@g10code.com>
* logging.c [W32]: Don't include unavailable headers. * logging.c [W32]: Don't include unavailable headers.

View File

@ -33,11 +33,24 @@
#include <io.h> #include <io.h>
#include <signal.h> #include <signal.h>
#include "logging.h" /* For log_get_prefix () */
/* We don't want to have any Windows specific code in the header, thus /* We don't want to have any Windows specific code in the header, thus
we use a macro which defaults to a compatible type in w32-pth.h. */ we use a macro which defaults to a compatible type in w32-pth.h. */
#define W32_PTH_HANDLE_INTERNAL HANDLE #define W32_PTH_HANDLE_INTERNAL HANDLE
#include "w32-pth.h" #include "w32-pth.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#if FALSE != 0 || TRUE != 1
#error TRUE or FALSE defined to wrong values
#endif
static int pth_initialized = 0; static int pth_initialized = 0;
@ -107,10 +120,12 @@ pth_init (void)
SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa;
WSADATA wsadat; WSADATA wsadat;
fprintf (stderr, "pth_init: called.\n"); if (pth_initialized)
pth_initialized = 1; return TRUE;
fprintf (stderr, "%s: pth_init: called.\n", log_get_prefix (NULL));
if (WSAStartup (0x202, &wsadat)) if (WSAStartup (0x202, &wsadat))
abort (); return FALSE;
pth_signo = 0; pth_signo = 0;
InitializeCriticalSection (&pth_shd); InitializeCriticalSection (&pth_shd);
if (pth_signo_ev) if (pth_signo_ev)
@ -121,9 +136,11 @@ pth_init (void)
sa.nLength = sizeof sa; sa.nLength = sizeof sa;
pth_signo_ev = CreateEvent (&sa, TRUE, FALSE, NULL); pth_signo_ev = CreateEvent (&sa, TRUE, FALSE, NULL);
if (!pth_signo_ev) if (!pth_signo_ev)
abort (); return FALSE;
pth_initialized = 1;
EnterCriticalSection (&pth_shd); EnterCriticalSection (&pth_shd);
return 0; return TRUE;
} }
@ -140,7 +157,7 @@ pth_kill (void)
DeleteCriticalSection (&pth_shd); DeleteCriticalSection (&pth_shd);
WSACleanup (); WSACleanup ();
pth_initialized = 0; pth_initialized = 0;
return 0; return TRUE;
} }
@ -160,7 +177,8 @@ enter_pth (const char *function)
{ {
/* Fixme: I am not sure whether the same thread my enter a critical /* Fixme: I am not sure whether the same thread my enter a critical
section twice. */ section twice. */
fprintf (stderr, "enter_pth (%s)\n", function? function:""); /* fprintf (stderr, "%s: enter_pth (%s)\n",
log_get_prefix (NULL), function? function:""); */
LeaveCriticalSection (&pth_shd); LeaveCriticalSection (&pth_shd);
} }
@ -169,7 +187,8 @@ static void
leave_pth (const char *function) leave_pth (const char *function)
{ {
EnterCriticalSection (&pth_shd); EnterCriticalSection (&pth_shd);
fprintf (stderr, "leave_pth (%s)\n", function? function:""); /* fprintf (stderr, "%s: leave_pth (%s)\n",
log_get_prefix (NULL), function? function:""); */
} }
@ -234,7 +253,8 @@ pth_read (int fd, void * buffer, size_t size)
{ {
char strerr[256]; char strerr[256];
fprintf (stderr, "pth_read(%d) failed read from file: %s\n", fd, fprintf (stderr, "%s: pth_read(%d) failed read from file: %s\n",
log_get_prefix (NULL), fd,
w32_strerror (strerr, sizeof strerr)); w32_strerror (strerr, sizeof strerr));
n = -1; n = -1;
} }
@ -273,7 +293,8 @@ pth_write (int fd, const void * buffer, size_t size)
n = WriteFile ((HANDLE)fd, buffer, size, &nwrite, NULL); n = WriteFile ((HANDLE)fd, buffer, size, &nwrite, NULL);
if (!n) if (!n)
{ {
fprintf (stderr, "pth_write(%d) failed in write: %s\n", fd, fprintf (stderr, "%s: pth_write(%d) failed in write: %s\n",
log_get_prefix (NULL), fd,
w32_strerror (strerr, sizeof strerr)); w32_strerror (strerr, sizeof strerr));
n = -1; n = -1;
} }
@ -437,7 +458,7 @@ pth_mutex_acquire (pth_mutex_t *hd, int tryonly, pth_event_t ev_extra)
if (!hd || !hd->mx) if (!hd || !hd->mx)
{ {
leave_pth (__FUNCTION__); leave_pth (__FUNCTION__);
return -1; return FALSE;
} }
#if 0 #if 0
@ -488,7 +509,7 @@ pth_mutex_acquire (pth_mutex_t *hd, int tryonly, pth_event_t ev_extra)
hd->mx_state |= PTH_MUTEX_LOCKED; hd->mx_state |= PTH_MUTEX_LOCKED;
leave_pth (__FUNCTION__); leave_pth (__FUNCTION__);
return 0; return TRUE;
} }
@ -513,7 +534,7 @@ pth_mutex_init (pth_mutex_t *hd)
hd->mx_state = PTH_MUTEX_INITIALIZED; hd->mx_state = PTH_MUTEX_INITIALIZED;
leave_pth (__FUNCTION__); leave_pth (__FUNCTION__);
return 0; return TRUE;
} }
@ -537,7 +558,7 @@ pth_attr_destroy (pth_attr_t hd)
if (hd->name) if (hd->name)
free (hd->name); free (hd->name);
free (hd); free (hd);
return 0; return TRUE;
} }
@ -547,7 +568,7 @@ pth_attr_set (pth_attr_t hd, int field, ...)
va_list args; va_list args;
char * str; char * str;
int val; int val;
int rc = 0; int rc = TRUE;
implicit_init (); implicit_init ();
@ -559,7 +580,8 @@ pth_attr_set (pth_attr_t hd, int field, ...)
if (val) if (val)
{ {
hd->flags |= PTH_ATTR_JOINABLE; hd->flags |= PTH_ATTR_JOINABLE;
fprintf (stderr, "pth_attr_set: PTH_ATTR_JOINABLE\n"); fprintf (stderr, "%s: pth_attr_set: PTH_ATTR_JOINABLE\n",
log_get_prefix (NULL));
} }
break; break;
@ -569,7 +591,8 @@ pth_attr_set (pth_attr_t hd, int field, ...)
{ {
hd->flags |= PTH_ATTR_STACK_SIZE; hd->flags |= PTH_ATTR_STACK_SIZE;
hd->stack_size = val; hd->stack_size = val;
fprintf (stderr, "pth_attr_set: PTH_ATTR_STACK_SIZE %d\n", val); fprintf (stderr, "%s: pth_attr_set: PTH_ATTR_STACK_SIZE %d\n",
log_get_prefix (NULL), val);
} }
break; break;
@ -581,14 +604,15 @@ pth_attr_set (pth_attr_t hd, int field, ...)
{ {
hd->name = strdup (str); hd->name = strdup (str);
if (!hd->name) if (!hd->name)
return -1; return FALSE;
hd->flags |= PTH_ATTR_NAME; hd->flags |= PTH_ATTR_NAME;
fprintf (stderr, "pth_attr_set: PTH_ATTR_NAME %s\n", hd->name); fprintf (stderr, "%s: pth_attr_set: PTH_ATTR_NAME %s\n",
log_get_prefix (NULL), hd->name);
} }
break; break;
default: default:
rc = -1; rc = FALSE;
break; break;
} }
va_end (args); va_end (args);
@ -627,12 +651,14 @@ do_pth_spawn (pth_attr_t hd, void *(*func)(void *), void *arg)
FIXME: We should no use th W32's Thread handle directly but keep FIXME: We should no use th W32's Thread handle directly but keep
our own thread control structure. CTX may be used for that. */ our own thread control structure. CTX may be used for that. */
fprintf (stderr, "do_pth_spawn creating thread ...\n"); fprintf (stderr, "%s: do_pth_spawn creating thread ...\n",
log_get_prefix (NULL));
th = CreateThread (&sa, hd->stack_size, th = CreateThread (&sa, hd->stack_size,
(LPTHREAD_START_ROUTINE)launch_thread, (LPTHREAD_START_ROUTINE)launch_thread,
ctx, CREATE_SUSPENDED, &tid); ctx, CREATE_SUSPENDED, &tid);
ctx->th = th; ctx->th = th;
fprintf (stderr, "do_pth_spawn created thread %p\n", th); fprintf (stderr, "%s: do_pth_spawn created thread %p\n",
log_get_prefix (NULL),th);
if (!th) if (!th)
free (ctx); free (ctx);
else else
@ -660,7 +686,7 @@ pth_spawn (pth_attr_t hd, void *(*func)(void *), void *arg)
int int
pth_join (pth_t hd, void **value) pth_join (pth_t hd, void **value)
{ {
return 0; return TRUE;
} }
@ -675,7 +701,7 @@ pth_cancel (pth_t hd)
WaitForSingleObject (hd, 1000); WaitForSingleObject (hd, 1000);
TerminateThread (hd, 0); TerminateThread (hd, 0);
leave_pth (__FUNCTION__); leave_pth (__FUNCTION__);
return 0; return TRUE;
} }
@ -689,7 +715,7 @@ pth_abort (pth_t hd)
enter_pth (__FUNCTION__); enter_pth (__FUNCTION__);
TerminateThread (hd, 0); TerminateThread (hd, 0);
leave_pth (__FUNCTION__); leave_pth (__FUNCTION__);
return 0; return TRUE;
} }
@ -759,7 +785,7 @@ sig_handler (DWORD signo)
case CTRL_BREAK_EVENT: pth_signo = SIGTERM; break; case CTRL_BREAK_EVENT: pth_signo = SIGTERM; break;
} }
SetEvent (pth_signo_ev); SetEvent (pth_signo_ev);
fprintf (stderr, "sig_handler=%d\n", pth_signo); fprintf (stderr, "%s: sig_handler=%d\n", log_get_prefix (NULL), pth_signo);
return TRUE; return TRUE;
} }
@ -771,7 +797,7 @@ do_pth_event_body (unsigned long spec, va_list arg)
pth_event_t ev; pth_event_t ev;
int rc; int rc;
fprintf (stderr, "pth_event spec=%lu\n", spec); fprintf (stderr, "%s: pth_event spec=%lu\n", log_get_prefix (NULL), spec);
ev = calloc (1, sizeof *ev); ev = calloc (1, sizeof *ev);
if (!ev) if (!ev)
return NULL; return NULL;
@ -783,7 +809,8 @@ do_pth_event_body (unsigned long spec, va_list arg)
ev->u_type = PTH_EVENT_SIGS; ev->u_type = PTH_EVENT_SIGS;
ev->val = va_arg (arg, int *); ev->val = va_arg (arg, int *);
rc = SetConsoleCtrlHandler (sig_handler, TRUE); rc = SetConsoleCtrlHandler (sig_handler, TRUE);
fprintf (stderr, "pth_event: sigs rc=%d\n", rc); fprintf (stderr, "%s: pth_event: sigs rc=%d\n",
log_get_prefix (NULL), rc);
} }
else if (spec & PTH_EVENT_FD) else if (spec & PTH_EVENT_FD)
{ {
@ -794,7 +821,8 @@ do_pth_event_body (unsigned long spec, va_list arg)
ev->u_type = PTH_EVENT_FD; ev->u_type = PTH_EVENT_FD;
va_arg (arg, pth_key_t); va_arg (arg, pth_key_t);
ev->u.fd = va_arg (arg, int); ev->u.fd = va_arg (arg, int);
fprintf (stderr, "pth_event: fd=%d\n", ev->u.fd); fprintf (stderr, "%s: pth_event: fd=%d\n",
log_get_prefix (NULL), ev->u.fd);
} }
else if (spec & PTH_EVENT_TIME) else if (spec & PTH_EVENT_TIME)
{ {
@ -908,7 +936,8 @@ wait_for_fd (int fd, int is_read, int nwait)
while (1) while (1)
{ {
n = select (fd+1, &r, &w, NULL, &tv); n = select (fd+1, &r, &w, NULL, &tv);
fprintf (stderr, "wait_for_fd=%d fd %d (ec=%d)\n", n, fd,(int)WSAGetLastError ()); fprintf (stderr, "%s: wait_for_fd=%d fd %d (ec=%d)\n",
log_get_prefix (NULL), n, fd,(int)WSAGetLastError ());
if (n == -1) if (n == -1)
break; break;
if (!n) if (!n)
@ -1005,7 +1034,8 @@ do_pth_event_occurred (pth_event_t ev)
if (sigpresent (ev->u.sig, pth_signo) && if (sigpresent (ev->u.sig, pth_signo) &&
WaitForSingleObject (pth_signo_ev, 0) == WAIT_OBJECT_0) WaitForSingleObject (pth_signo_ev, 0) == WAIT_OBJECT_0)
{ {
fprintf (stderr, "pth_event_occurred: sig signaled.\n"); fprintf (stderr, "%s: pth_event_occurred: sig signaled.\n",
log_get_prefix (NULL));
(*ev->val) = pth_signo; (*ev->val) = pth_signo;
ret = 1; ret = 1;
} }
@ -1080,7 +1110,7 @@ do_pth_event_free (pth_event_t ev, int mode)
free (ev); free (ev);
} }
return 0; return TRUE;
} }
int int
@ -1134,11 +1164,13 @@ spawn_helper_thread (void *(*func)(void *), void *arg)
sa.lpSecurityDescriptor = NULL; sa.lpSecurityDescriptor = NULL;
sa.nLength = sizeof sa; sa.nLength = sizeof sa;
fprintf (stderr, "spawn_helper_thread creating thread ...\n"); fprintf (stderr, "%s: spawn_helper_thread creating thread ...\n",
log_get_prefix (NULL));
th = CreateThread (&sa, 32*1024, th = CreateThread (&sa, 32*1024,
(LPTHREAD_START_ROUTINE)func, (LPTHREAD_START_ROUTINE)func,
arg, 0, &tid); arg, 0, &tid);
fprintf (stderr, "spawn_helper_thread created thread %p\n", th); fprintf (stderr, "%s: spawn_helper_thread created thread %p\n",
log_get_prefix (NULL), th);
return th; return th;
} }
@ -1163,7 +1195,7 @@ wait_fd_thread (void * ctx)
pth_event_t ev = ctx; pth_event_t ev = ctx;
wait_for_fd (ev->u.fd, ev->flags & PTH_UNTIL_FD_READABLE, 3600); wait_for_fd (ev->u.fd, ev->flags & PTH_UNTIL_FD_READABLE, 3600);
fprintf (stderr, "wait_fd_thread: exit.\n"); fprintf (stderr, "%s: wait_fd_thread: exit.\n", log_get_prefix (NULL));
SetEvent (ev->hd); SetEvent (ev->hd);
ExitThread (0); ExitThread (0);
return NULL; return NULL;
@ -1177,7 +1209,7 @@ wait_timer_thread (void * ctx)
int n = ev->u.tv.tv_sec*1000; int n = ev->u.tv.tv_sec*1000;
Sleep (n); Sleep (n);
SetEvent (ev->hd); SetEvent (ev->hd);
fprintf (stderr, "wait_timer_thread: exit.\n"); fprintf (stderr, "%s: wait_timer_thread: exit.\n", log_get_prefix (NULL));
ExitThread (0); ExitThread (0);
return NULL; return NULL;
} }
@ -1199,7 +1231,7 @@ do_pth_wait (pth_event_t ev)
if (n > MAXIMUM_WAIT_OBJECTS/2) if (n > MAXIMUM_WAIT_OBJECTS/2)
return -1; return -1;
fprintf (stderr, "pth_wait: cnt %lu\n", n); fprintf (stderr, "%s: pth_wait: cnt %lu\n", log_get_prefix (NULL), n);
for (tmp = ev; tmp; tmp = tmp->next) for (tmp = ev; tmp; tmp = tmp->next)
{ {
switch (tmp->u_type) switch (tmp->u_type)
@ -1233,10 +1265,10 @@ do_pth_wait (pth_event_t ev)
break; break;
} }
} }
fprintf (stderr, "pth_wait: set %d\n", pos); fprintf (stderr, "%s: pth_wait: set %d\n", log_get_prefix (NULL), pos);
n = WaitForMultipleObjects (pos, waitbuf, FALSE, INFINITE); n = WaitForMultipleObjects (pos, waitbuf, FALSE, INFINITE);
free_helper_threads (waitbuf, hdidx, i); free_helper_threads (waitbuf, hdidx, i);
fprintf (stderr, "pth_wait: n %ld\n", n); fprintf (stderr, "%s: pth_wait: n %ld\n", log_get_prefix (NULL), n);
if (n != WAIT_TIMEOUT) if (n != WAIT_TIMEOUT)
return 1; return 1;

View File

@ -1,5 +1,7 @@
2004-12-18 Werner Koch <wk@g10code.com> 2004-12-18 Werner Koch <wk@g10code.com>
* scdaemon.c (main) [W32]: Remove special Pth initialize..
* scdaemon.h (map_assuan_err): Define in terms of * scdaemon.h (map_assuan_err): Define in terms of
map_assuan_err_with_source. map_assuan_err_with_source.

View File

@ -158,10 +158,8 @@ static char socket_name[128];
#ifndef HAVE_OPENSC #ifndef HAVE_OPENSC
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
#ifndef HAVE_W32_SYSTEM
/* Pth wrapper function definitions. */ /* Pth wrapper function definitions. */
GCRY_THREAD_OPTION_PTH_IMPL; GCRY_THREAD_OPTION_PTH_IMPL;
#endif
static void *ticker_thread (void *arg); static void *ticker_thread (void *arg);
#endif /*USE_GNU_PTH*/ #endif /*USE_GNU_PTH*/
@ -353,16 +351,12 @@ main (int argc, char **argv )
Note that this will also do the pth_init. */ Note that this will also do the pth_init. */
#ifndef HAVE_OPENSC #ifndef HAVE_OPENSC
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
# ifdef HAVE_W32_SYSTEM
pth_init ();
# else /*!HAVE_W32_SYSTEM*/
err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth); err = gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pth);
if (err) if (err)
{ {
log_fatal ("can't register GNU Pth with Libgcrypt: %s\n", log_fatal ("can't register GNU Pth with Libgcrypt: %s\n",
gpg_strerror (err)); gpg_strerror (err));
} }
# endif /*!HAVE_W32_SYSTEM*/
#endif /*USE_GNU_PTH*/ #endif /*USE_GNU_PTH*/
#endif /*!HAVE_OPENSC*/ #endif /*!HAVE_OPENSC*/

View File

@ -740,6 +740,7 @@ main ( int argc, char **argv)
} }
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
/* For W32 we need pth. */
pth_init (); pth_init ();
#endif #endif