diff options
author | Werner Koch <wk@gnupg.org> | 2014-04-08 17:06:02 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-04-08 17:06:17 +0200 |
commit | db85feceaf43ebd6d44421bb14fcb60495804ae0 (patch) | |
tree | 7c9df68b6120c3ac7ec7e2a7b28c82c68665901d /dirmngr | |
parent | gpgconf: Add command --launch. (diff) | |
download | gnupg2-db85feceaf43ebd6d44421bb14fcb60495804ae0.tar.xz gnupg2-db85feceaf43ebd6d44421bb14fcb60495804ae0.zip |
dirmngr: Fix compiler warning.
* common/mischelp.h (JNLIB_GCC_HAVE_PUSH_PRAGMA): New.
* dirmngr/dirmngr.c (handle_tick): Factor time check out to ...
(time_for_housekeeping_p): new.
--
I am not sure whether that y2038 hack is really useful but it might
make me smile in my retirement.
Diffstat (limited to 'dirmngr')
-rw-r--r-- | dirmngr/dirmngr.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c index ab657202c..81da029a3 100644 --- a/dirmngr/dirmngr.c +++ b/dirmngr/dirmngr.c @@ -1686,18 +1686,36 @@ housekeeping_thread (void *arg) } -/* This is the worker for the ticker. It is called every few seconds - and may only do fast operations. */ -static void -handle_tick (void) +#if JNLIB_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; - time_t curtime; - curtime = gnupg_get_time (); 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 JNLIB_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) +{ /* Under Windows we don't use signals and need a way for the loop to check for the shutdown flag. */ #ifdef HAVE_W32_SYSTEM @@ -1712,16 +1730,12 @@ handle_tick (void) } #endif /*HAVE_W32_SYSTEM*/ - /* Start a housekeeping thread every 10 minutes */ - if (last_housekeeping + HOUSEKEEPING_INTERVAL <= curtime - || last_housekeeping > curtime /*(be prepared for y2038)*/) + if (time_for_housekeeping_p (gnupg_get_time ())) { npth_t thread; npth_attr_t tattr; int err; - last_housekeeping = curtime; - err = npth_attr_init (&tattr); if (err) log_error ("error preparing housekeeping thread: %s\n", strerror (err)); |