Ian Jackson <ijack...@chiark.greenend.org.uk> wrote: > I think that at least my patch > [PATCH 4/4] gpg agent lockup fix: Interrupt main loop when > active_connections_value==0 > is very likely a fix to an actual race. [...] > I would like this bug fixed in stretch.
I think that this issue is a bug in the patches of debian/patches/gpg-agent-idling/. I confirmed the possibility where the main thread might block at npth_pselect forever. There are connections, shutdown_pending is set by signal, npth_pselect is called, then connections are finished. The main thread keeps staying at npth_pselect. For me, it is a bit difficult to apply the fourth patch only. So, I seek the update of the patch: 0003-agent-Avoid-tight-timer-tick-when-possible.patch How about changing the need_tick function, instead? My intention is to make the behavior of gpg-agent as similar as upstream version. I mean, changing the first hunk of the patch of gnupg/agent/gpg-agent.c, like this (adding the check against shutdown_pending). --- gnupg.orig/agent/gpg-agent.c +++ gnupg/agent/gpg-agent.c @@ -2267,6 +2267,29 @@ create_directories (void) } +static int +need_tick (void) +{ +#ifdef HAVE_W32_SYSTEM + /* We do not know how to interrupt the select loop on Windows, so we + always need a short tick there. */ + return 1; +#else + /* if we were invoked like "gpg-agent cmd arg1 arg2" then we need to + watch our parent. */ + if (parent_pid != (pid_t)(-1)) + return 1; + /* if scdaemon is running, we need to check that it's alive */ + if (agent_scd_check_running ()) + return 1; + /* if a shutdown was requested, we wait all connections closing. */ + if (shutdown_pending) + return 1; + /* otherwise, nothing fine-grained to do. */ + return 0; +#endif /*HAVE_W32_SYSTEM*/ +} + /* This is the worker for the ticker. It is called every few seconds and may only do fast operations. */ --