[git] GnuPG - branch, master, updated. gnupg-2.1.18-46-g8ddc926

by NIIBE Yutaka cvs at cvs.gnupg.org
Wed Feb 1 01:03:39 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  8ddc9268f6aedef0e178b174b89245c33d8189dd (commit)
      from  2e78aa6ff770849415f8eb71ca70c8886e9564c8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8ddc9268f6aedef0e178b174b89245c33d8189dd
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Wed Feb 1 08:58:01 2017 +0900

    scd: Fix regression tracking the connection count.
    
    * scd/scdaemon.c (get_active_connection_count): New.
    (start_connection_thread): Bump ACTIVE_CONNECTIONS up and down.
    * scd/command.c (cmd_getinfo): Add subcommand "connections".
    
    --
    
    Apply gpg-agent change to scdaemon.  See the commit in 2016-08-06:
        40d16029ed8b334c371fa7f24ac762d47302826e
    
    Then, add kicking the loop, so that main loop can notice the change of
    the connection.
    
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/scd/command.c b/scd/command.c
index 0ae6d29..bd7e803 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -1372,30 +1372,26 @@ static const char hlp_getinfo[] =
   "Multi purpose command to return certain information.  \n"
   "Supported values of WHAT are:\n"
   "\n"
-  "version     - Return the version of the program.\n"
-  "pid         - Return the process id of the server.\n"
-  "\n"
-  "socket_name - Return the name of the socket.\n"
-  "\n"
-  "status - Return the status of the current reader (in the future, may\n"
-  "also return the status of all readers).  The status is a list of\n"
-  "one-character flags.  The following flags are currently defined:\n"
-  "  'u'  Usable card present.  This is the normal state during operation.\n"
-  "  'r'  Card removed.  A reset is necessary.\n"
-  "These flags are exclusive.\n"
-  "\n"
-  "reader_list - Return a list of detected card readers.  Does\n"
-  "              currently only work with the internal CCID driver.\n"
-  "\n"
-  "deny_admin  - Returns OK if admin commands are not allowed or\n"
-  "              GPG_ERR_GENERAL if admin commands are allowed.\n"
-  "\n"
-  "app_list    - Return a list of supported applications.  One\n"
-  "              application per line, fields delimited by colons,\n"
-  "              first field is the name.\n"
-  "\n"
-  "card_list   - Return a list of serial numbers of active cards,\n"
-  "              using a status response.";
+  "  version     - Return the version of the program.\n"
+  "  pid         - Return the process id of the server.\n"
+  "  socket_name - Return the name of the socket.\n"
+  "  connections - Return number of active connections.\n"
+  "  status      - Return the status of the current reader (in the future,\n"
+  "                may also return the status of all readers).  The status\n"
+  "                is a list of one-character flags.  The following flags\n"
+  "                are currently defined:\n"
+  "                  'u'  Usable card present.\n"
+  "                  'r'  Card removed.  A reset is necessary.\n"
+  "                These flags are exclusive.\n"
+  "  reader_list - Return a list of detected card readers.  Does\n"
+  "                currently only work with the internal CCID driver.\n"
+  "  deny_admin  - Returns OK if admin commands are not allowed or\n"
+  "                GPG_ERR_GENERAL if admin commands are allowed.\n"
+  "  app_list    - Return a list of supported applications.  One\n"
+  "                application per line, fields delimited by colons,\n"
+  "                first field is the name.\n"
+  "  card_list   - Return a list of serial numbers of active cards,\n"
+  "                using a status response.";
 static gpg_error_t
 cmd_getinfo (assuan_context_t ctx, char *line)
 {
@@ -1422,6 +1418,13 @@ cmd_getinfo (assuan_context_t ctx, char *line)
       else
         rc = gpg_error (GPG_ERR_NO_DATA);
     }
+  else if (!strcmp (line, "connections"))
+    {
+      char numbuf[20];
+
+      snprintf (numbuf, sizeof numbuf, "%d", get_active_connection_count ());
+      rc = assuan_send_data (ctx, numbuf, strlen (numbuf));
+    }
   else if (!strcmp (line, "status"))
     {
       ctrl_t ctrl = assuan_get_pointer (ctx);
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 7972abd..e4b0ef8 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -1150,6 +1150,8 @@ start_connection_thread (void *arg)
       return NULL;
     }
 
+  active_connections++;
+
   scd_init_default_ctrl (ctrl);
   if (opt.verbose)
     log_info (_("handler for fd %d started\n"),
@@ -1169,6 +1171,10 @@ start_connection_thread (void *arg)
 
   scd_deinit_default_ctrl (ctrl);
   xfree (ctrl);
+
+  if (--active_connections == 0)
+    scd_kick_the_loop ();
+
   return NULL;
 }
 
@@ -1349,3 +1355,10 @@ handle_connections (int listen_fd)
   log_info (_("%s %s stopped\n"), strusage(11), strusage(13));
   npth_attr_destroy (&tattr);
 }
+
+/* Return the number of active connections. */
+int
+get_active_connection_count (void)
+{
+  return active_connections;
+}
diff --git a/scd/scdaemon.h b/scd/scdaemon.h
index 37590b6..4797f3d 100644
--- a/scd/scdaemon.h
+++ b/scd/scdaemon.h
@@ -125,6 +125,7 @@ void send_status_info (ctrl_t ctrl, const char *keyword, ...)
 void send_status_direct (ctrl_t ctrl, const char *keyword, const char *args);
 void send_client_notifications (app_t app, int removal);
 void scd_kick_the_loop (void);
+int get_active_connection_count (void);
 
 /*-- app.c --*/
 int scd_update_reader_status_file (void);

-----------------------------------------------------------------------

Summary of changes:
 scd/command.c  | 51 +++++++++++++++++++++++++++------------------------
 scd/scdaemon.c | 13 +++++++++++++
 scd/scdaemon.h |  1 +
 3 files changed, 41 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list