diff options
author | Werner Koch <[email protected]> | 2004-12-19 17:44:20 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-12-19 17:44:20 +0000 |
commit | 8f22f895e94d45755c99470eb76fd9fd508b5b5f (patch) | |
tree | c428f9546b0f65eeb0189214b1ebabeededd65ec /agent | |
parent | * maperror.c (map_assuan_err_with_source): Oops, args were swapped. (diff) | |
download | gnupg-8f22f895e94d45755c99470eb76fd9fd508b5b5f.tar.gz gnupg-8f22f895e94d45755c99470eb76fd9fd508b5b5f.zip |
* query.c (initialize_module_query):
* call-scd.c (initialize_module_call_scd): New.
* w32-pth.c (pth_init): Enable debugging depending on env var.
(pth_self): New.
(pth_mutex_release, pth_mutex_acquire): Implemented directly using
the W32 API.
Diffstat (limited to 'agent')
-rw-r--r-- | agent/ChangeLog | 6 | ||||
-rw-r--r-- | agent/agent.h | 2 | ||||
-rw-r--r-- | agent/call-scd.c | 21 | ||||
-rw-r--r-- | agent/gpg-agent.c | 4 | ||||
-rw-r--r-- | agent/query.c | 21 |
5 files changed, 51 insertions, 3 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog index 52673e5b3..d3c4af337 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,9 @@ +2004-12-19 Werner Koch <[email protected]> + + * query.c (initialize_module_query): + + * call-scd.c (initialize_module_call_scd): New. + 2004-12-18 Werner Koch <[email protected]> * gpg-agent.c (main): Remove special Pth initialize. diff --git a/agent/agent.h b/agent/agent.h index 7ff692504..e6c8e2a35 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -145,6 +145,7 @@ gpg_error_t agent_key_from_file (ctrl_t ctrl, int agent_key_available (const unsigned char *grip); /*-- query.c --*/ +void initialize_module_query (void); int agent_askpin (ctrl_t ctrl, const char *desc_text, const char *inital_errtext, struct pin_entry_info_s *pininfo); @@ -212,6 +213,7 @@ int divert_generic_cmd (ctrl_t ctrl, /*-- call-scd.c --*/ +void initialize_module_call_scd (void); int agent_reset_scd (ctrl_t ctrl); int agent_card_learn (ctrl_t ctrl, void (*kpinfo_cb)(void*, const char *), diff --git a/agent/call-scd.c b/agent/call-scd.c index 828040772..90c625f8b 100644 --- a/agent/call-scd.c +++ b/agent/call-scd.c @@ -52,7 +52,7 @@ static ASSUAN_CONTEXT scd_ctx = NULL; #ifdef USE_GNU_PTH -static pth_mutex_t scd_lock = PTH_MUTEX_INIT; +static pth_mutex_t scd_lock; #endif /* We need to keep track of the connection currently using the SCD. For a pipe server this is all a NOP because the connection will @@ -153,6 +153,23 @@ get_membuf (struct membuf *mb, size_t *len) +/* This function must be called once to initialize this module. This + has to be done before a second thread is spawned. We can't do the + static initialization because Pth emulation code might not be able + to do a static init; in particualr, it is not possible for W32. */ +void +initialize_module_call_scd (void) +{ +#ifdef USE_GNU_PTH + static int initialized; + + if (!initialized) + if (pth_mutex_init (&scd_lock)) + initialized = 1; +#endif /*USE_GNU_PTH*/ +} + + static int unlock_scd (int rc) { @@ -163,7 +180,7 @@ unlock_scd (int rc) if (!rc) rc = gpg_error (GPG_ERR_INTERNAL); } -#endif +#endif /*USE_GNU_PTH*/ return rc; } diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index ed12fed4f..65d5fd5a6 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -627,6 +627,10 @@ main (int argc, char **argv ) exit (1); } + initialize_module_query (); + initialize_module_call_scd (); + + /* Try to create missing directories. */ create_directories (); if (debug_wait && pipe_server) diff --git a/agent/query.c b/agent/query.c index b514f6f5e..4aafcbe99 100644 --- a/agent/query.c +++ b/agent/query.c @@ -51,7 +51,7 @@ static ASSUAN_CONTEXT entry_ctx = NULL; #ifdef USE_GNU_PTH -static pth_mutex_t entry_lock = PTH_MUTEX_INIT; +static pth_mutex_t entry_lock; #endif /* data to be passed to our callbacks */ @@ -64,6 +64,25 @@ struct entry_parm_s { +/* This function must be called once to initialize this module. This + has to be done before a second thread is spawned. We can't do the + static initialization because Pth emulation code might not be able + to do a static init; in particualr, it is not possible for W32. */ +void +initialize_module_query (void) +{ +#ifdef USE_GNU_PTH + static int initialized; + + if (!initialized) + if (pth_mutex_init (&entry_lock)) + initialized = 1; +#endif /*USE_GNU_PTH*/ +} + + + + /* Unlock the pinentry so that another thread can start one and disconnect that pinentry - we do this after the unlock so that a stalled pinentry does not block other threads. Fixme: We should |