Again, this doesn't seem to be easy to make controllable at runtime. Signed-off-by: Ian Jackson <ijack...@chiark.greenend.org.uk> --- common/asshelp.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/common/asshelp.c b/common/asshelp.c index 2cab310..341dfe3 100644 --- a/common/asshelp.c +++ b/common/asshelp.c @@ -76,6 +76,15 @@ static int (*my_log_monitor) (assuan_context_t ctx, const char *msg); +#define DLOG(m, ...) do{ \ + int DLOG_se = errno; \ + if (/*DBG_IPC*/ 0) \ + log_debug("asshelp " m, \ + ##__VA_ARGS__); \ + errno = DLOG_se; \ + }while(0) + + static int my_libassuan_log_handler (assuan_context_t ctx, void *hook, unsigned int cat, const char *msg) @@ -270,6 +279,8 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name, char *fname; (void)verbose; + DLOG("lock_spawning(,%s,%s)\n", homedir, name); + *lock = NULL; fname = make_absfilename_try @@ -299,6 +310,8 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name, static void unlock_spawning (lock_spawn_t *lock, const char *name) { + DLOG("unlock_spawning(%p, %s)\n", lock, name); + if (*lock) { (void)name; @@ -330,6 +343,8 @@ start_new_gpg_agent (assuan_context_t *r_ctx, *r_ctx = NULL; + DLOG("start_new_gpg_agent(autostart=%d)...\n",autostart); + err = assuan_new (&ctx); if (err) { @@ -345,6 +360,8 @@ start_new_gpg_agent (assuan_context_t *r_ctx, return err; } + DLOG("start_new_gpg_agent sockname=%s...\n",sockname); + err = assuan_socket_connect (ctx, sockname, 0, 0); if (err && autostart) { @@ -356,6 +373,8 @@ start_new_gpg_agent (assuan_context_t *r_ctx, const char *s; int i; + DLOG("start_new_gpg_agent err=%d, spawning...\n",err); + /* With no success start a new server. */ if (!agent_program || !*agent_program) agent_program = gnupg_module_name (GNUPG_MODULE_NAME_AGENT); @@ -369,6 +388,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, gpg_err_code_from_syserror ()); xfree (sockname); assuan_release (ctx); + DLOG("start_new_gpg_agent ERROR %ld (xstrdup)\n", (long)tmperr); return tmperr; } p = strchr (program, '|'); @@ -396,6 +416,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, xfree (sockname); assuan_release (ctx); xfree (program); + DLOG("start_new_gpg_agent ERROR %ld (abs_homedir)\n", (long)tmperr); return tmperr; } @@ -409,6 +430,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, assuan_release (ctx); xfree (abs_homedir); xfree (program); + DLOG("start_new_gpg_agent ERROR %ld (fflush)\n", (long)tmperr); return tmperr; } @@ -424,9 +446,11 @@ start_new_gpg_agent (assuan_context_t *r_ctx, argv[i++] = "--daemon"; argv[i++] = NULL; + DLOG("start_new_gpg_agent locking spawning...\n"); if (!(err = lock_spawning (&lock, gnupg_homedir (), "agent", verbose)) && assuan_socket_connect (ctx, sockname, 0, 0)) { + DLOG("start_new_gpg_agent locked spawning, no connect...\n"); err = gnupg_spawn_process_detached (program? program : agent_program, argv, NULL); if (err) @@ -436,6 +460,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, { for (i=0; i < SECS_TO_WAIT_FOR_AGENT; i++) { + DLOG("start_new_gpg_agent waiting %d...\n", i); if (verbose) log_info (_("waiting for the agent to come up ... (%ds)\n"), SECS_TO_WAIT_FOR_AGENT - i); @@ -453,6 +478,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, } } } + DLOG("start_new_gpg_agent lock failed or connect failed...\n"); unlock_spawning (&lock, "agent"); xfree (abs_homedir); @@ -461,6 +487,8 @@ start_new_gpg_agent (assuan_context_t *r_ctx, xfree (sockname); if (err) { + DLOG("start_new_gpg_agent ERROR (connect)\n"); + if (autostart || gpg_err_code (err) != GPG_ERR_ASS_CONNECT_FAILED) log_error ("can't connect to the agent: %s\n", gpg_strerror (err)); assuan_release (ctx); @@ -493,10 +521,12 @@ start_new_gpg_agent (assuan_context_t *r_ctx, if (err) { assuan_release (ctx); + DLOG("start_new_gpg_agent ERROR %ld (final)\n", (long)err); return err; } *r_ctx = ctx; + DLOG("start_new_gpg_agent=%p OK\n", ctx); return 0; } -- 2.11.0