1 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2 Date: Sat, 29 Oct 2016 02:15:08 -0400
3 Subject: dirmngr: Drop useless housekeeping.
5 * dirmngr/dirmngr.c (handle_tick, time_for_housekeeping_p,
6 housekeeping_thread): Remove, no longer needed.
7 (handle_connections): Drop any attempt at a timeout, since no
8 housekeeping is necessary.
12 The housekeeping thread no longer does anything, and the main loop was
13 waking up every 60 seconds for no good reason. The code is simpler
14 and the runtime is more efficient if we drop this.
16 Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
18 dirmngr/dirmngr.c | 113 +++---------------------------------------------------
19 1 file changed, 5 insertions(+), 108 deletions(-)
21 diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
22 index 58a424e8c..0b8bb02e6 100644
23 --- a/dirmngr/dirmngr.c
24 +++ b/dirmngr/dirmngr.c
25 @@ -304,13 +304,6 @@ static int active_connections;
26 * thread to run background network tasks. */
27 static int network_activity_seen;
29 -/* The timer tick used for housekeeping stuff. */
30 -#define TIMERTICK_INTERVAL (60)
32 -/* How oft to run the housekeeping. */
33 -#define HOUSEKEEPING_INTERVAL (600)
36 /* This union is used to avoid compiler warnings in case a pointer is
37 64 bit and an int 32 bit. We store an integer in a pointer and get
38 it back later (npth_getspecific et al.). */
39 @@ -1768,83 +1761,6 @@ handle_signal (int signo)
40 #endif /*!HAVE_W32_SYSTEM*/
43 -/* Thread to do the housekeeping. */
45 -housekeeping_thread (void *arg)
47 - static int sentinel;
53 - log_info ("housekeeping is already going on\n");
57 - if (opt.verbose > 1)
58 - log_info ("starting housekeeping\n");
60 - if (opt.verbose > 1)
61 - log_info ("ready with housekeeping\n");
68 -#if GPGRT_GCC_HAVE_PUSH_PRAGMA
69 -# pragma GCC push_options
70 -# pragma GCC optimize ("no-strict-overflow")
73 -time_for_housekeeping_p (time_t curtime)
75 - static time_t last_housekeeping;
77 - if (!last_housekeeping)
78 - last_housekeeping = curtime;
80 - if (last_housekeeping + HOUSEKEEPING_INTERVAL <= curtime
81 - || last_housekeeping > curtime /*(be prepared for y2038)*/)
83 - last_housekeeping = curtime;
88 -#if GPGRT_GCC_HAVE_PUSH_PRAGMA
89 -# pragma GCC pop_options
93 -/* This is the worker for the ticker. It is called every few seconds
94 - and may only do fast operations. */
98 - if (time_for_housekeeping_p (gnupg_get_time ()))
104 - err = npth_attr_init (&tattr);
106 - log_error ("error preparing housekeeping thread: %s\n", strerror (err));
109 - npth_attr_setdetachstate (&tattr, NPTH_CREATE_DETACHED);
110 - err = npth_create (&thread, &tattr, housekeeping_thread, NULL);
112 - log_error ("error spawning housekeeping thread: %s\n",
114 - npth_attr_destroy (&tattr);
120 /* Check the nonce on a new connection. This is a NOP unless we are
121 using our Unix domain socket emulation under Windows. */
123 @@ -1945,9 +1861,6 @@ handle_connections (assuan_fd_t listen_fd)
126 fd_set fdset, read_fdset;
127 - struct timespec abstime;
128 - struct timespec curtime;
129 - struct timespec timeout;
131 int my_inotify_fd = -1;
133 @@ -1987,9 +1900,7 @@ handle_connections (assuan_fd_t listen_fd)
134 #endif /*HAVE_INOTIFY_INIT*/
137 - /* Setup the fdset. It has only one member. This is because we use
138 - pth_select instead of pth_accept to properly sync timeouts with
140 + /* Setup the fdset. */
142 FD_SET (FD2INT (listen_fd), &fdset);
143 nfd = FD2INT (listen_fd);
144 @@ -2000,9 +1911,6 @@ handle_connections (assuan_fd_t listen_fd)
148 - npth_clock_gettime (&abstime);
149 - abstime.tv_sec += TIMERTICK_INTERVAL;
154 @@ -2013,7 +1921,7 @@ handle_connections (assuan_fd_t listen_fd)
157 /* Do not accept new connections but keep on running the
158 - * loop to cope with the timer events.
159 + * select loop to wait for signals (e.g. SIGCHLD).
161 * Note that we do not close the listening socket because a
162 * client trying to connect to that socket would instead
163 @@ -2033,24 +1941,14 @@ handle_connections (assuan_fd_t listen_fd)
164 /* Take a copy of the fdset. */
167 - npth_clock_gettime (&curtime);
168 - if (!(npth_timercmp (&curtime, &abstime, <)))
172 - npth_clock_gettime (&abstime);
173 - abstime.tv_sec += TIMERTICK_INTERVAL;
175 - npth_timersub (&abstime, &curtime, &timeout);
177 #ifndef HAVE_W32_SYSTEM
178 - ret = npth_pselect (nfd+1, &read_fdset, NULL, NULL, &timeout, npth_sigev_sigmask());
179 + ret = npth_pselect (nfd+1, &read_fdset, NULL, NULL, NULL, npth_sigev_sigmask());
182 while (npth_sigev_get_pending(&signo))
183 handle_signal (signo);
185 - ret = npth_eselect (nfd+1, &read_fdset, NULL, NULL, &timeout, NULL, NULL);
186 + ret = npth_eselect (nfd+1, &read_fdset, NULL, NULL, NULL, NULL, NULL);
190 @@ -2064,8 +1962,7 @@ handle_connections (assuan_fd_t listen_fd)
194 - /* Interrupt or timeout. Will be handled when calculating the
196 + /* Interrupt. Will be handled at the top of the next loop. */