[Pkg-gnupg-commit] [gnupg2] 22/42: Change backlog from 5 to 64 and provide option --listen-backlog.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Jan 3 18:25:54 UTC 2018


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch upstream
in repository gnupg2.

commit c81a447190d2763ac4c64b2e74e22e824da8aba3
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Dec 12 14:14:40 2017 +0100

    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 at gnupg.org>
---
 agent/gpg-agent.c  | 16 ++++++++++++++--
 dirmngr/dirmngr.c  | 15 +++++++++++++--
 doc/dirmngr.texi   |  4 ++++
 doc/gpg-agent.texi |  3 +++
 doc/scdaemon.texi  |  6 ++++++
 scd/scdaemon.c     | 16 +++++++++++++---
 6 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 21beb29..a1964ec 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);
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 9cb0203..17adae2 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -151,6 +151,7 @@ enum cmd_and_opt_values {
   oResolverTimeout,
   oConnectTimeout,
   oConnectQuickTimeout,
+  oListenBacklog,
   aTest
 };
 
@@ -256,6 +257,7 @@ static ARGPARSE_OPTS opts[] = {
   ARGPARSE_s_i (oResolverTimeout, "resolver-timeout", "@"),
   ARGPARSE_s_i (oConnectTimeout, "connect-timeout", "@"),
   ARGPARSE_s_i (oConnectQuickTimeout, "connect-quick-timeout", "@"),
+  ARGPARSE_s_i (oListenBacklog, "listen-backlog", "@"),
 
   ARGPARSE_group (302,N_("@\n(See the \"info\" manual for a complete listing "
                          "of all commands and options)\n")),
@@ -296,6 +298,10 @@ static const char *redir_socket_name;
    POSIX systems). */
 static assuan_sock_nonce_t socket_nonce;
 
+/* Value for the listen() backlog argument.
+ * Change at runtime with --listen-backlog.  */
+static int listen_backlog = 64;
+
 /* Only if this flag has been set will we remove the socket file.  */
 static int cleanup_socket;
 
@@ -1019,6 +1025,10 @@ main (int argc, char **argv)
 
         case oSocketName: socket_name = pargs.r.ret_str; break;
 
+        case oListenBacklog:
+          listen_backlog = pargs.r.ret_int;
+          break;
+
         default : pargs.err = configfp? 1:2; break;
 	}
     }
@@ -1263,9 +1273,10 @@ main (int argc, char **argv)
         log_error (_("can't set permissions of '%s': %s\n"),
                    serv_addr.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));
           assuan_sock_close (fd);
           dirmngr_exit (1);
         }
diff --git a/doc/dirmngr.texi b/doc/dirmngr.texi
index 9654a0e..800955c 100644
--- a/doc/dirmngr.texi
+++ b/doc/dirmngr.texi
@@ -282,6 +282,10 @@ default values are 15 and 2 seconds.  Note that the timeout values are
 for each connection attempt; the connection code will attempt to
 connect all addresses listed for a server.
 
+ at item --listen-backlog @var{n}
+ at opindex listen-backlog
+Set the size of the queue for pending connections.  The default is 64.
+
 @item --allow-version-check
 @opindex allow-version-check
 Allow Dirmngr to connect to @code{https://versions.gnupg.org} to get
diff --git a/doc/gpg-agent.texi b/doc/gpg-agent.texi
index 65df970..3e8bd89 100644
--- a/doc/gpg-agent.texi
+++ b/doc/gpg-agent.texi
@@ -563,6 +563,9 @@ Ignore requests to change the current @code{tty} or X window system's
 @code{DISPLAY} variable respectively.  This is useful to lock the
 pinentry to pop up at the @code{tty} or display you started the agent.
 
+ at item --listen-backlog @var{n}
+ at opindex listen-backlog
+Set the size of the queue for pending connections.  The default is 64.
 
 @anchor{option --extra-socket}
 @item --extra-socket @var{name}
diff --git a/doc/scdaemon.texi b/doc/scdaemon.texi
index 4c6bb93..a9e6d1e 100644
--- a/doc/scdaemon.texi
+++ b/doc/scdaemon.texi
@@ -236,6 +236,12 @@ a list of categories see the Libassuan manual.
 Don't detach the process from the console.  This is mainly useful for
 debugging.
 
+ at item --listen-backlog @var{n}
+ at opindex listen-backlog
+Set the size of the queue for pending connections.  The default is 64.
+This option has an effect only if @option{--multi-server} is also
+used.
+
 @item --log-file @var{file}
 @opindex log-file
 Append all logging output to @var{file}.  This is very helpful in
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 0bedb8d..3ad2657 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -99,6 +99,7 @@ enum cmd_and_opt_values
   oDenyAdmin,
   oDisableApplication,
   oEnablePinpadVarlen,
+  oListenBacklog
 };
 
 
@@ -156,6 +157,7 @@ static ARGPARSE_OPTS opts[] = {
   ARGPARSE_s_n (oEnablePinpadVarlen, "enable-pinpad-varlen",
                 N_("use variable length input for pinpad")),
   ARGPARSE_s_s (oHomedir,    "homedir",      "@"),
+  ARGPARSE_s_i (oListenBacklog, "listen-backlog", "@"),
 
   ARGPARSE_end ()
 };
@@ -224,6 +226,10 @@ static char *redir_socket_name;
    POSIX systems). */
 static assuan_sock_nonce_t socket_nonce;
 
+/* Value for the listen() backlog argument.  Change at runtime with
+ * --listen-backlog.  */
+static int listen_backlog = 64;
+
 #ifdef HAVE_W32_SYSTEM
 static HANDLE the_event;
 #else
@@ -594,6 +600,10 @@ main (int argc, char **argv )
 
         case oEnablePinpadVarlen: opt.enable_pinpad_varlen = 1; break;
 
+        case oListenBacklog:
+          listen_backlog = pargs.r.ret_int;
+          break;
+
         default:
           pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR;
           break;
@@ -1128,10 +1138,10 @@ create_server_socket (const char *name, char **r_redir_name,
     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"),
-                 gpg_strerror (gpg_error_from_syserror ()));
+      log_error ("listen(fd, %d) failed: %s\n",
+                 listen_backlog, gpg_strerror (gpg_error_from_syserror ()));
       assuan_sock_close (fd);
       scd_exit (2);
     }

-- 
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