aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/dirmngr.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-07-26 08:02:52 +0000
committerWerner Koch <[email protected]>2017-07-26 08:27:36 +0000
commitd50c2eff8d6931586c527edb3dea98dbc6facdec (patch)
tree842f13b0a188a94e0c49c053a6cdd9222f8f0a7d /dirmngr/dirmngr.c
parentagent: Lengthen timertick interval on Unix to 4 seconds. (diff)
downloadgnupg-d50c2eff8d6931586c527edb3dea98dbc6facdec.tar.gz
gnupg-d50c2eff8d6931586c527edb3dea98dbc6facdec.zip
agent,dirmngr: Check for homedir removal also using stat(2).
* agent/gpg-agent.c (have_homedir_inotify): New var. (reliable_homedir_inotify): New var. (main): Set reliable_homedir_inotify. (handle_tick): Call stat on the homedir. (handle_connections): Mark availibility of the inotify watch. * dirmngr/dirmngr.c (handle_tick): Call stat on the homedir. (TIMERTICK_INTERVAL_SHUTDOWN): New. (handle_connections): Depend tick interval on the shutdown state. -- The stat call is used on systems which do not support inotify and also when we assume that the inotify does not work reliable. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'dirmngr/dirmngr.c')
-rw-r--r--dirmngr/dirmngr.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 5f3a4cd18..1ddc568a0 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -334,8 +334,9 @@ static int network_activity_seen;
static strlist_t hkp_cacert_filenames;
-/* The timer tick used for housekeeping stuff. */
-#define TIMERTICK_INTERVAL (60)
+/* 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)
@@ -1967,6 +1968,8 @@ time_for_housekeeping_p (time_t curtime)
static void
handle_tick (void)
{
+ struct stat statbuf;
+
if (time_for_housekeeping_p (gnupg_get_time ()))
{
npth_t thread;
@@ -1986,6 +1989,14 @@ handle_tick (void)
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");
+ }
}
@@ -2179,10 +2190,13 @@ handle_connections (assuan_fd_t listen_fd)
npth_clock_gettime (&curtime);
if (!(npth_timercmp (&curtime, &abstime, <)))
{
- /* Timeout. */
+ /* 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 += TIMERTICK_INTERVAL;
+ abstime.tv_sec += (shutdown_pending
+ ? TIMERTICK_INTERVAL_SHUTDOWN
+ : TIMERTICK_INTERVAL);
}
npth_timersub (&abstime, &curtime, &timeout);