summaryrefslogtreecommitdiffstats
path: root/agent
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2017-12-12 14:14:40 +0100
committerWerner Koch <wk@gnupg.org>2017-12-12 14:14:40 +0100
commitc81a447190d2763ac4c64b2e74e22e824da8aba3 (patch)
treef1234bef88b3bab5d44e9e9718f62aa5b2a74d7b /agent
parentbuild: New configure option --enable-run-gnupg-user-socket. (diff)
downloadgnupg2-c81a447190d2763ac4c64b2e74e22e824da8aba3.tar.xz
gnupg2-c81a447190d2763ac4c64b2e74e22e824da8aba3.zip
Change backlog from 5 to 64 and provide option --listen-backlog.
* agent/gpg-agent.c (oListenBacklog): New const. (opts): New option --listen-backlog. (listen_backlog): New var. (main): Parse new options. (create_server_socket): Use var instead of 5. * dirmngr/dirmngr.c: Likewise. * scd/scdaemon.c: Likewise. -- GnuPG-bug-id: 3473 Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'agent')
-rw-r--r--agent/gpg-agent.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 21beb29c7..a1964ece8 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -136,6 +136,7 @@ enum cmd_and_opt_values
oDisableCheckOwnSocket,
oS2KCount,
oAutoExpandSecmem,
+ oListenBacklog,
oWriteEnvFile
};
@@ -255,6 +256,8 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_op_u (oAutoExpandSecmem, "auto-expand-secmem", "@"),
+ ARGPARSE_s_i (oListenBacklog, "listen-backlog", "@"),
+
/* Dummy options for backward compatibility. */
ARGPARSE_o_s (oWriteEnvFile, "write-env-file", "@"),
ARGPARSE_s_n (oUseStandardSocket, "use-standard-socket", "@"),
@@ -371,6 +374,10 @@ static assuan_sock_nonce_t socket_nonce_extra;
static assuan_sock_nonce_t socket_nonce_browser;
static assuan_sock_nonce_t socket_nonce_ssh;
+/* Value for the listen() backlog argument. We use the same value for
+ * all sockets - 64 is on current Linux half of the default maximum.
+ * Let's try this as default. Change at runtime with --listen-backlog. */
+static int listen_backlog = 64;
/* Default values for options passed to the pinentry. */
static char *default_display;
@@ -1245,6 +1252,10 @@ main (int argc, char **argv )
(unsigned int)pargs.r.ret_ulong, 0);
break;
+ case oListenBacklog:
+ listen_backlog = pargs.r.ret_int;
+ break;
+
case oDebugQuickRandom:
/* Only used by the first stage command line parser. */
break;
@@ -2248,9 +2259,10 @@ create_server_socket (char *name, int primary, int cygwin,
log_error (_("can't set permissions of '%s': %s\n"),
unaddr->sun_path, strerror (errno));
- if (listen (FD2INT(fd), 5 ) == -1)
+ if (listen (FD2INT(fd), listen_backlog ) == -1)
{
- log_error (_("listen() failed: %s\n"), strerror (errno));
+ log_error ("listen(fd,%d) failed: %s\n",
+ listen_backlog, strerror (errno));
*name = 0; /* Inhibit removal of the socket by cleanup(). */
assuan_sock_close (fd);
xfree (unaddr);