[Pkg-gnupg-commit] [gnupg2] 03/16: dirmngr: cannot avoid idling in current arrangement

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Feb 6 04:20:13 UTC 2018


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

dkg pushed a commit to branch master
in repository gnupg2.

commit eca73102a5f54bec0eacb5a198f52e727cf9b535
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date:   Wed Jan 3 12:23:49 2018 -0500

    dirmngr: cannot avoid idling in current arrangement
    
    since the new background task framework was added in
    f2997adee0455c8c0fa391a853ec1b0c9fc43342, we can't avoid the
    housekeeping thread in the way we have been.
    
    This probably warrants more improvements upstream, but i don't have
    the time to craft them right now.
---
 ...void-automatically-checking-upstream-swdb.patch |  44 ++---
 .../dirmngr-Drop-useless-housekeeping.patch        | 213 ---------------------
 debian/patches/series                              |   1 -
 3 files changed, 12 insertions(+), 246 deletions(-)

diff --git a/debian/patches/dirmngr-idling/dirmngr-Avoid-automatically-checking-upstream-swdb.patch b/debian/patches/dirmngr-idling/dirmngr-Avoid-automatically-checking-upstream-swdb.patch
index 7a8cfae..7729b15 100644
--- a/debian/patches/dirmngr-idling/dirmngr-Avoid-automatically-checking-upstream-swdb.patch
+++ b/debian/patches/dirmngr-idling/dirmngr-Avoid-automatically-checking-upstream-swdb.patch
@@ -10,46 +10,26 @@ checks only confuse the user.
 
 Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
 ---
- dirmngr/dirmngr.c | 13 -------------
- doc/dirmngr.texi  |  7 ++++---
- 2 files changed, 4 insertions(+), 16 deletions(-)
+ dirmngr/dirmngr.c | 2 --
+ doc/dirmngr.texi  | 7 ++++---
+ 2 files changed, 4 insertions(+), 5 deletions(-)
 
 diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
-index d11b018..318c257 100644
+index 8be069f..b3766fb 100644
 --- a/dirmngr/dirmngr.c
 +++ b/dirmngr/dirmngr.c
-@@ -1912,7 +1912,6 @@ static void *
- housekeeping_thread (void *arg)
- {
-   static int sentinel;
--  struct server_control_s ctrlbuf;
- 
-   (void)arg;
- 
-@@ -1925,18 +1924,6 @@ housekeeping_thread (void *arg)
-   if (opt.verbose > 1)
-     log_info ("starting housekeeping\n");
- 
--  memset (&ctrlbuf, 0, sizeof ctrlbuf);
--  dirmngr_init_default_ctrl (&ctrlbuf);
--
--  if (network_activity_seen)
--    {
--      network_activity_seen = 0;
+@@ -1945,8 +1945,6 @@ housekeeping_thread (void *arg)
+   if (network_activity_seen)
+     {
+       network_activity_seen = 0;
 -      if (opt.allow_version_check)
 -        dirmngr_load_swdb (&ctrlbuf, 0);
--    }
--
--  dirmngr_deinit_default_ctrl (&ctrlbuf);
--
-   if (opt.verbose > 1)
-     log_info ("ready with housekeeping\n");
-   sentinel--;
-diff --git a/doc/dirmngr.texi b/doc/dirmngr.texi
-index 9654a0e..ee9fa46 100644
+       workqueue_run_global_tasks (&ctrlbuf, 1);
+     }
+   else
 --- a/doc/dirmngr.texi
 +++ b/doc/dirmngr.texi
-@@ -285,9 +285,10 @@ connect all addresses listed for a server.
+@@ -289,9 +289,10 @@
  @item --allow-version-check
  @opindex allow-version-check
  Allow Dirmngr to connect to @code{https://versions.gnupg.org} to get
diff --git a/debian/patches/dirmngr-idling/dirmngr-Drop-useless-housekeeping.patch b/debian/patches/dirmngr-idling/dirmngr-Drop-useless-housekeeping.patch
deleted file mode 100644
index 5c1ccef..0000000
--- a/debian/patches/dirmngr-idling/dirmngr-Drop-useless-housekeeping.patch
+++ /dev/null
@@ -1,213 +0,0 @@
-From: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
-Date: Sat, 29 Oct 2016 02:15:08 -0400
-Subject: dirmngr: Drop useless housekeeping.
-
-* dirmngr/dirmngr.c (handle_tick, time_for_housekeeping_p,
-housekeeping_thread): Remove, no longer needed.
-(handle_connections): Drop any attempt at a timeout, since no
-housekeeping is necessary.
-
---
-
-The housekeeping thread no longer does anything, and the main loop was
-waking up every 60 seconds for no good reason.  The code is simpler
-and the runtime is more efficient if we drop this.
-
-Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
----
- dirmngr/dirmngr.c | 127 +++---------------------------------------------------
- 1 file changed, 6 insertions(+), 121 deletions(-)
-
-diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
-index 318c257..b8d5d6f 100644
---- a/dirmngr/dirmngr.c
-+++ b/dirmngr/dirmngr.c
-@@ -334,14 +334,6 @@ static int network_activity_seen;
- static strlist_t hkp_cacert_filenames;
- 
- 
--/* The timer tick used for housekeeping stuff.  The second constant is used when a shutdown is pending.  */
--#define TIMERTICK_INTERVAL           (60)
--#define TIMERTICK_INTERVAL_SHUTDOWN  (4)
--
--/* How oft to run the housekeeping.  */
--#define HOUSEKEEPING_INTERVAL      (600)
--
--
- /* This union is used to avoid compiler warnings in case a pointer is
-    64 bit and an int 32 bit.  We store an integer in a pointer and get
-    it back later (npth_getspecific et al.).  */
-@@ -1907,93 +1899,6 @@ handle_signal (int signo)
- #endif /*!HAVE_W32_SYSTEM*/
- 
- 
--/* Thread to do the housekeeping.  */
--static void *
--housekeeping_thread (void *arg)
--{
--  static int sentinel;
--
--  (void)arg;
--
--  if (sentinel)
--    {
--      log_info ("housekeeping is already going on\n");
--      return NULL;
--    }
--  sentinel++;
--  if (opt.verbose > 1)
--    log_info ("starting housekeeping\n");
--
--  if (opt.verbose > 1)
--    log_info ("ready with housekeeping\n");
--  sentinel--;
--  return NULL;
--
--}
--
--
--#if GPGRT_GCC_HAVE_PUSH_PRAGMA
--# pragma GCC push_options
--# pragma GCC optimize ("no-strict-overflow")
--#endif
--static int
--time_for_housekeeping_p (time_t curtime)
--{
--  static time_t last_housekeeping;
--
--  if (!last_housekeeping)
--    last_housekeeping = curtime;
--
--  if (last_housekeeping + HOUSEKEEPING_INTERVAL <= curtime
--      || last_housekeeping > curtime /*(be prepared for y2038)*/)
--    {
--      last_housekeeping = curtime;
--      return 1;
--    }
--  return 0;
--}
--#if GPGRT_GCC_HAVE_PUSH_PRAGMA
--# pragma GCC pop_options
--#endif
--
--
--/* This is the worker for the ticker.  It is called every few seconds
--   and may only do fast operations. */
--static void
--handle_tick (void)
--{
--  struct stat statbuf;
--
--  if (time_for_housekeeping_p (gnupg_get_time ()))
--    {
--      npth_t thread;
--      npth_attr_t tattr;
--      int err;
--
--      err = npth_attr_init (&tattr);
--      if (err)
--        log_error ("error preparing housekeeping thread: %s\n", strerror (err));
--      else
--        {
--          npth_attr_setdetachstate (&tattr, NPTH_CREATE_DETACHED);
--          err = npth_create (&thread, &tattr, housekeeping_thread, NULL);
--          if (err)
--            log_error ("error spawning housekeeping thread: %s\n",
--                       strerror (err));
--          npth_attr_destroy (&tattr);
--        }
--    }
--
--  /* Check whether the homedir is still available.  */
--  if (!shutdown_pending
--      && stat (gnupg_homedir (), &statbuf) && errno == ENOENT)
--    {
--      shutdown_pending = 1;
--      log_info ("homedir has been removed - shutting down\n");
--    }
--}
--
--
- /* Check the nonce on a new connection.  This is a NOP unless we are
-    using our Unix domain socket emulation under Windows.  */
- static int
-@@ -2093,8 +1998,6 @@ handle_connections (assuan_fd_t listen_fd)
-   socklen_t plen = sizeof( paddr );
-   int nfd, ret;
-   fd_set fdset, read_fdset;
--  struct timespec abstime;
--  struct timespec curtime;
-   struct timespec timeout;
-   int saved_errno;
-   int my_inotify_fd = -1;
-@@ -2135,9 +2038,7 @@ handle_connections (assuan_fd_t listen_fd)
- #endif /*HAVE_INOTIFY_INIT*/
- 
- 
--  /* Setup the fdset.  It has only one member.  This is because we use
--     pth_select instead of pth_accept to properly sync timeouts with
--     to full second.  */
-+  /* Setup the fdset.  */
-   FD_ZERO (&fdset);
-   FD_SET (FD2INT (listen_fd), &fdset);
-   nfd = FD2INT (listen_fd);
-@@ -2148,9 +2049,6 @@ handle_connections (assuan_fd_t listen_fd)
-         nfd = my_inotify_fd;
-     }
- 
--  npth_clock_gettime (&abstime);
--  abstime.tv_sec += TIMERTICK_INTERVAL;
--
-   /* Main loop.  */
-   for (;;)
-     {
-@@ -2161,7 +2059,7 @@ 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.
-+           * select loop to wait for signals (e.g. SIGCHLD).
-            *
-            * Note that we do not close the listening socket because a
-            * client trying to connect to that socket would instead
-@@ -2181,27 +2079,14 @@ handle_connections (assuan_fd_t listen_fd)
-       /* Take a copy of the fdset.  */
-       read_fdset = fdset;
- 
--      npth_clock_gettime (&curtime);
--      if (!(npth_timercmp (&curtime, &abstime, <)))
--	{
--	  /* Timeout.  When a shutdown is pending we use a shorter
--           * interval to handle the shutdown more quickly.  */
--	  handle_tick ();
--	  npth_clock_gettime (&abstime);
--	  abstime.tv_sec += (shutdown_pending
--                             ? TIMERTICK_INTERVAL_SHUTDOWN
--                             : TIMERTICK_INTERVAL);
--	}
--      npth_timersub (&abstime, &curtime, &timeout);
--
- #ifndef HAVE_W32_SYSTEM
--      ret = npth_pselect (nfd+1, &read_fdset, NULL, NULL, &timeout, npth_sigev_sigmask());
-+      ret = npth_pselect (nfd+1, &read_fdset, NULL, NULL, NULL, npth_sigev_sigmask());
-       saved_errno = errno;
- 
-       while (npth_sigev_get_pending(&signo))
- 	handle_signal (signo);
- #else
--      ret = npth_eselect (nfd+1, &read_fdset, NULL, NULL, &timeout, NULL, NULL);
-+      ret = npth_eselect (nfd+1, &read_fdset, NULL, NULL, NULL, NULL, NULL);
-       saved_errno = errno;
- #endif
- 
-@@ -2215,8 +2100,8 @@ handle_connections (assuan_fd_t listen_fd)
- 
-       if (ret <= 0)
-         {
--          /* Interrupt or timeout.  Will be handled when calculating the
--             next timeout.  */
-+          /* Interrupt.  Will be handled at the top of the next
-+             loop.  */
-           continue;
-         }
- 
diff --git a/debian/patches/series b/debian/patches/series
index 619b3e7..1bc9a96 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,7 +4,6 @@ block-ptrace-on-secret-daemons/Avoid-simple-memory-dumps-via-ptrace.patch
 dirmngr-idling/dirmngr-hkp-Avoid-potential-race-condition-when-some.patch
 dirmngr-idling/dirmngr-Avoid-need-for-hkp-housekeeping.patch
 dirmngr-idling/dirmngr-Avoid-automatically-checking-upstream-swdb.patch
-dirmngr-idling/dirmngr-Drop-useless-housekeeping.patch
 gpg-agent-idling/agent-Create-framework-of-scheduled-timers.patch
 gpg-agent-idling/agent-Allow-threads-to-interrupt-main-select-loop-wi.patch
 gpg-agent-idling/agent-Avoid-tight-timer-tick-when-possible.patch

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