[git] GnuPG - branch, master, updated. gnupg-2.2.1-78-g5d83eb9

by Werner Koch cvs at cvs.gnupg.org
Mon Nov 13 12:04:27 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  5d83eb9226c0ce608ec284d8c9bc22ce84a00c25 (commit)
      from  80b904543486a2f12087bc34a6049ede4eb75940 (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 5d83eb9226c0ce608ec284d8c9bc22ce84a00c25
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Nov 13 10:52:36 2017 +0100

    gpg-agent: Avoid getting stuck in shutdown pending state.
    
    * agent/gpg-agent.c (handle_connections): Always check inotify fds.
    --
    
    I noticed a gpg-agent processed, probably in shutdown_pending state,
    which was selecting on only these two inotify fds.  The select
    returned immediately but because we did not handle the fds in
    shutdown_pending state they were not read and the next select call
    returned one of them immediately again.  Actually that should not
    hanppen because the
    
              if (active_connections == 0)
                break; /* ready */
    
    should have terminated the loop.  For unknown reasons (maybe be just a
    connection thread terminated in a gdb session) that did not happen.
    By moving the check outside of the shutdown_pending condition and
    closing the fd after they have been triggered the code should be more
    robust.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 2e19d19..0b2b982 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -3000,27 +3000,34 @@ handle_connections (gnupg_fd_t listen_fd,
 	   next timeout.  */
 	continue;
 
+      /* The inotify fds are set even when a shutdown is pending (see
+       * above).  So we must handle them in any case.  To avoid that
+       * they trigger a second time we close them immediately.  */
+      if (sock_inotify_fd != -1
+          && FD_ISSET (sock_inotify_fd, &read_fdset)
+          && gnupg_inotify_has_name (sock_inotify_fd, GPG_AGENT_SOCK_NAME))
+        {
+          shutdown_pending = 1;
+          close (sock_inotify_fd);
+          sock_inotify_fd = -1;
+          log_info ("socket file has been removed - shutting down\n");
+        }
+
+      if (home_inotify_fd != -1
+          && FD_ISSET (home_inotify_fd, &read_fdset))
+        {
+          shutdown_pending = 1;
+          close (home_inotify_fd);
+          home_inotify_fd = -1;
+          log_info ("homedir has been removed - shutting down\n");
+        }
+
       if (!shutdown_pending)
         {
           int idx;
           ctrl_t ctrl;
           npth_t thread;
 
-          if (sock_inotify_fd != -1
-              && FD_ISSET (sock_inotify_fd, &read_fdset)
-              && gnupg_inotify_has_name (sock_inotify_fd, GPG_AGENT_SOCK_NAME))
-            {
-              shutdown_pending = 1;
-              log_info ("socket file has been removed - shutting down\n");
-            }
-
-          if (home_inotify_fd != -1
-              && FD_ISSET (home_inotify_fd, &read_fdset))
-            {
-              shutdown_pending = 1;
-              log_info ("homedir has been removed - shutting down\n");
-            }
-
           for (idx=0; idx < DIM(listentbl); idx++)
             {
               if (listentbl[idx].l_fd == GNUPG_INVALID_FD)

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

Summary of changes:
 agent/gpg-agent.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)


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




More information about the Gnupg-commits mailing list