[Pkg-gnupg-commit] [gnupg2] 50/112: agent: Fix long standing regression tracking the connection count.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Aug 30 17:48:19 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit 40d16029ed8b334c371fa7f24ac762d47302826e
Author: Werner Koch <wk at gnupg.org>
Date: Sat Aug 6 10:14:17 2016 +0200
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 <wk at gnupg.org>
---
agent/agent.h | 1 +
agent/command.c | 9 +++++++++
agent/gpg-agent.c | 12 ++++++++++++
3 files changed, 22 insertions(+)
diff --git a/agent/agent.h b/agent/agent.h
index 42a580c..fe5ffba 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -341,6 +341,7 @@ void agent_set_progress_cb (void (*cb)(ctrl_t ctrl, const char *what,
gpg_error_t agent_copy_startup_env (ctrl_t ctrl);
const char *get_agent_socket_name (void);
const char *get_agent_ssh_socket_name (void);
+int get_agent_active_connection_count (void);
#ifdef HAVE_W32_SYSTEM
void *get_agent_scd_notify_event (void);
#endif
diff --git a/agent/command.c b/agent/command.c
index 1803b5f..7fc28ad 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -2775,6 +2775,7 @@ static const char hlp_getinfo[] =
" std_startup_env - List the standard startup environment.\n"
" cmd_has_option\n"
" - Returns OK if the command CMD implements the option OPT.\n"
+ " connections - Return number of active connections.\n"
" restricted - Returns OK if the connection is in restricted mode.\n";
static gpg_error_t
cmd_getinfo (assuan_context_t ctx, char *line)
@@ -2907,6 +2908,14 @@ cmd_getinfo (assuan_context_t ctx, char *line)
}
}
}
+ else if (!strcmp (line, "connections"))
+ {
+ char numbuf[20];
+
+ snprintf (numbuf, sizeof numbuf, "%d",
+ get_agent_active_connection_count ());
+ rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
+ }
else
rc = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT");
return rc;
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 90b0eaf..8a957cc 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;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list