mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
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.
This commit is contained in:
parent
b4cf4686f7
commit
db85feceaf
@ -52,10 +52,12 @@ time_t timegm (struct tm *tm);
|
|||||||
#define DIMof(type,member) DIM(((type *)0)->member)
|
#define DIMof(type,member) DIM(((type *)0)->member)
|
||||||
|
|
||||||
|
|
||||||
|
#undef JNLIB_GCC_HAVE_PUSH_PRAGMA
|
||||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
|
||||||
# define JNLIB_GCC_M_FUNCTION 1
|
# define JNLIB_GCC_M_FUNCTION 1
|
||||||
# define JNLIB_GCC_A_NR __attribute__ ((noreturn))
|
# define JNLIB_GCC_A_NR __attribute__ ((noreturn))
|
||||||
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
|
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 )
|
||||||
|
# define JNLIB_GCC_HAVE_PUSH_PRAGMA 1
|
||||||
# define JNLIB_GCC_A_PRINTF( f, a ) \
|
# define JNLIB_GCC_A_PRINTF( f, a ) \
|
||||||
__attribute__ ((format (__gnu_printf__,f,a)))
|
__attribute__ ((format (__gnu_printf__,f,a)))
|
||||||
# define JNLIB_GCC_A_NR_PRINTF( f, a ) \
|
# define JNLIB_GCC_A_NR_PRINTF( f, a ) \
|
||||||
|
@ -1686,18 +1686,36 @@ housekeeping_thread (void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
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
|
/* This is the worker for the ticker. It is called every few seconds
|
||||||
and may only do fast operations. */
|
and may only do fast operations. */
|
||||||
static void
|
static void
|
||||||
handle_tick (void)
|
handle_tick (void)
|
||||||
{
|
{
|
||||||
static time_t last_housekeeping;
|
|
||||||
time_t curtime;
|
|
||||||
|
|
||||||
curtime = gnupg_get_time ();
|
|
||||||
if (!last_housekeeping)
|
|
||||||
last_housekeeping = curtime;
|
|
||||||
|
|
||||||
/* Under Windows we don't use signals and need a way for the loop to
|
/* Under Windows we don't use signals and need a way for the loop to
|
||||||
check for the shutdown flag. */
|
check for the shutdown flag. */
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
@ -1712,16 +1730,12 @@ handle_tick (void)
|
|||||||
}
|
}
|
||||||
#endif /*HAVE_W32_SYSTEM*/
|
#endif /*HAVE_W32_SYSTEM*/
|
||||||
|
|
||||||
/* Start a housekeeping thread every 10 minutes */
|
if (time_for_housekeeping_p (gnupg_get_time ()))
|
||||||
if (last_housekeeping + HOUSEKEEPING_INTERVAL <= curtime
|
|
||||||
|| last_housekeeping > curtime /*(be prepared for y2038)*/)
|
|
||||||
{
|
{
|
||||||
npth_t thread;
|
npth_t thread;
|
||||||
npth_attr_t tattr;
|
npth_attr_t tattr;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
last_housekeeping = curtime;
|
|
||||||
|
|
||||||
err = npth_attr_init (&tattr);
|
err = npth_attr_init (&tattr);
|
||||||
if (err)
|
if (err)
|
||||||
log_error ("error preparing housekeeping thread: %s\n", strerror (err));
|
log_error ("error preparing housekeeping thread: %s\n", strerror (err));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user