From 40d16029ed8b334c371fa7f24ac762d47302826e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Sat, 6 Aug 2016 10:14:17 +0200 Subject: agent: Fix long standing regression tracking the connection count. * agent/gpg-agent.c (get_agent_active_connection_count): New. (do_start_connection_thread, start_connection_thread_ssh): Bump ACTIVE_CONNECTIONS up and down. * agent/command.c (cmd_getinfo): Add subcommand "connections". -- The variable ACTIVE_CONNECTIONS is used to shutdown gpg-agent in a friendly way. Before we switched to nPth a Pth provided count of threads was used for this. During the migration to nPth ACTIVE_CONNECTIONS was introduced and checked but never set. Signed-off-by: Werner Koch --- agent/gpg-agent.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'agent/gpg-agent.c') diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index 90b0eaf35..8a957cc36 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -1694,6 +1694,14 @@ get_agent_ssh_socket_name (void) } +/* Return the number of active connections. */ +int +get_agent_active_connection_count (void) +{ + return active_connections; +} + + /* Under W32, this function returns the handle of the scdaemon notification event. Calling it the first time creates that event. */ @@ -2302,6 +2310,7 @@ putty_message_thread (void *arg) static void * do_start_connection_thread (ctrl_t ctrl) { + active_connections++; agent_init_default_ctrl (ctrl); if (opt.verbose) log_info (_("handler 0x%lx for fd %d started\n"), @@ -2314,6 +2323,7 @@ do_start_connection_thread (ctrl_t ctrl) agent_deinit_default_ctrl (ctrl); xfree (ctrl); + active_connections--; return NULL; } @@ -2380,6 +2390,7 @@ start_connection_thread_ssh (void *arg) if (check_nonce (ctrl, &socket_nonce_ssh)) return NULL; + active_connections++; agent_init_default_ctrl (ctrl); if (opt.verbose) log_info (_("ssh handler 0x%lx for fd %d started\n"), @@ -2392,6 +2403,7 @@ start_connection_thread_ssh (void *arg) agent_deinit_default_ctrl (ctrl); xfree (ctrl); + active_connections--; return NULL; } -- cgit v1.2.3