[git] GnuPG - branch, master, updated. gnupg-2.1.16-40-gaa6ab9e

by Werner Koch cvs at cvs.gnupg.org
Tue Nov 29 20:38:00 CET 2016


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  aa6ab9e0bc67fe9ce5601047e84ea4a875e8eb64 (commit)
       via  854adc8ae19749e44cb79dfa0c5401f48012b13a (commit)
      from  8489b12211098ad58c008cfb74b5cb91849cf68d (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 aa6ab9e0bc67fe9ce5601047e84ea4a875e8eb64
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Nov 29 20:35:10 2016 +0100

    agent,dirmngr: Tiny restructuring.
    
    * agent/gpg-agent.c (handle_connections): Add a comment.
    * dirmngr/dirmngr.c (main): Move assuan_sock_close of the listening
    socket to ...
    (handle_connections): here.  Add a comment why we keep the
    listening socket open during a shutdown.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index c2052c9..710357c 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -2829,7 +2829,12 @@ handle_connections (gnupg_fd_t listen_fd,
             break; /* ready */
 
           /* Do not accept new connections but keep on running the
-             loop to cope with the timer events.  */
+           * loop to cope with the timer events.
+           *
+           * Note that we do not close the listening socket because a
+           * client trying to connect to that socket would instead
+           * restart a new dirmngr instance - which is unlikely the
+           * intention of a shutdown. */
           FD_ZERO (&fdset);
           nfd = -1;
           if (my_inotify_fd != -1)
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 748f309..191f772 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -1026,7 +1026,6 @@ main (int argc, char **argv)
       crl_cache_init ();
       http_register_netactivity_cb (netactivity_action);
       handle_connections (3);
-      assuan_sock_close (3);
       shutdown_reaper ();
     }
 #endif /*HAVE_W32_SYSTEM*/
@@ -1234,7 +1233,6 @@ main (int argc, char **argv)
       crl_cache_init ();
       http_register_netactivity_cb (netactivity_action);
       handle_connections (fd);
-      assuan_sock_close (fd);
       shutdown_reaper ();
     }
   else if (cmd == aListCRLs)
@@ -1925,7 +1923,8 @@ my_inotify_is_name (int fd, const char *name)
 #endif /*HAVE_INOTIFY_INIT*/
 
 
-/* Main loop in daemon mode. */
+/* Main loop in daemon mode.  Note that LISTEN_FD will be owned by
+ * this function. */
 static void
 handle_connections (assuan_fd_t listen_fd)
 {
@@ -2006,7 +2005,14 @@ handle_connections (assuan_fd_t listen_fd)
             break; /* ready */
 
           /* Do not accept new connections but keep on running the
-             loop to cope with the timer events.  */
+           * loop to cope with the timer events.
+           *
+           * Note that we do not close the listening socket because a
+           * client trying to connect to that socket would instead
+           * restart a new dirmngr instance - which is unlikely the
+           * intention of a shutdown. */
+          /* assuan_sock_close (listen_fd); */
+          /* listen_fd = -1; */
           FD_ZERO (&fdset);
           nfd = -1;
           if (my_inotify_fd != -1)
@@ -2109,6 +2115,8 @@ handle_connections (assuan_fd_t listen_fd)
     close (my_inotify_fd);
 #endif /*HAVE_INOTIFY_INIT*/
   npth_attr_destroy (&tattr);
+  if (listen_fd != -1)
+    assuan_sock_close (fd);
   cleanup ();
   log_info ("%s %s stopped\n", strusage(11), strusage(13));
 }

commit 854adc8ae19749e44cb79dfa0c5401f48012b13a
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Nov 29 20:15:47 2016 +0100

    agent,dirmngr: Handle corner case in shutdown mode.
    
    * agent/gpg-agent.c (handle_connections): Keep on selecting on the
    inotify fd even when a shutdown is pending.
    * dirmngr/dirmngr.c (handle_connections): Ditto.  Also simplifyy the
    use of the HAVE_INOTIFY_INIT cpp conditional.
    --
    
    Without that patch we won't notice a removed socket when a shutdown is
    pending.  This is somewhat related to bug report 2849.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 5060c07..c2052c9 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -2831,6 +2831,12 @@ handle_connections (gnupg_fd_t listen_fd,
           /* Do not accept new connections but keep on running the
              loop to cope with the timer events.  */
           FD_ZERO (&fdset);
+          nfd = -1;
+          if (my_inotify_fd != -1)
+            {
+              FD_SET (my_inotify_fd, &fdset);
+              nfd = my_inotify_fd;
+            }
 	}
 
       /* POSIX says that fd_set should be implemented as a structure,
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index f60173b..748f309 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -1942,9 +1942,7 @@ handle_connections (assuan_fd_t listen_fd)
   struct timespec curtime;
   struct timespec timeout;
   int saved_errno;
-#ifdef HAVE_INOTIFY_INIT
-  int my_inotify_fd;
-#endif /*HAVE_INOTIFY_INIT*/
+  int my_inotify_fd = -1;
 
   npth_attr_init (&tattr);
   npth_attr_setdetachstate (&tattr, NPTH_CREATE_DETACHED);
@@ -1988,14 +1986,12 @@ handle_connections (assuan_fd_t listen_fd)
   FD_ZERO (&fdset);
   FD_SET (FD2INT (listen_fd), &fdset);
   nfd = FD2INT (listen_fd);
-#ifdef HAVE_INOTIFY_INIT
   if (my_inotify_fd != -1)
     {
       FD_SET (my_inotify_fd, &fdset);
       if (my_inotify_fd > nfd)
         nfd = my_inotify_fd;
     }
-#endif /*HAVE_INOTIFY_INIT*/
 
   npth_clock_gettime (&abstime);
   abstime.tv_sec += TIMERTICK_INTERVAL;
@@ -2012,6 +2008,12 @@ handle_connections (assuan_fd_t listen_fd)
           /* Do not accept new connections but keep on running the
              loop to cope with the timer events.  */
           FD_ZERO (&fdset);
+          nfd = -1;
+          if (my_inotify_fd != -1)
+            {
+              FD_SET (my_inotify_fd, &fdset);
+              nfd = my_inotify_fd;
+            }
 	}
 
       /* Take a copy of the fdset.  */

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

Summary of changes:
 agent/gpg-agent.c | 13 ++++++++++++-
 dirmngr/dirmngr.c | 28 +++++++++++++++++++---------
 2 files changed, 31 insertions(+), 10 deletions(-)


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




More information about the Gnupg-commits mailing list