summaryrefslogtreecommitdiff
path: root/lib/isc/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/isc/timer.c')
-rw-r--r--lib/isc/timer.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/lib/isc/timer.c b/lib/isc/timer.c
index 6a6acf6bb081b..d002b11722ce6 100644
--- a/lib/isc/timer.c
+++ b/lib/isc/timer.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
- * Copyright (C) 1998-2002 Internet Software Consortium.
+ * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1998-2003 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: timer.c,v 1.64.12.13 2006/01/04 23:50:21 marka Exp $ */
+/* $Id: timer.c,v 1.64.12.17 2007/10/24 01:08:01 marka Exp $ */
#include <config.h>
@@ -582,6 +582,7 @@ dispatch(isc_timermgr_t *manager, isc_time_t *now) {
isc_eventtype_t type = 0;
isc_timer_t *timer;
isc_result_t result;
+ isc_boolean_t idle;
/*
* The caller must be holding the manager lock.
@@ -613,23 +614,33 @@ dispatch(isc_timermgr_t *manager, isc_time_t *now) {
type = ISC_TIMEREVENT_LIFE;
post_event = ISC_TRUE;
need_schedule = ISC_FALSE;
- } else if (!isc_time_isepoch(&timer->idle) &&
- isc_time_compare(now,
- &timer->idle) >= 0) {
- type = ISC_TIMEREVENT_IDLE;
- post_event = ISC_TRUE;
- need_schedule = ISC_FALSE;
} else {
- /*
- * Idle timer has been touched; reschedule.
- */
- XTRACEID(isc_msgcat_get(isc_msgcat,
- ISC_MSGSET_TIMER,
- ISC_MSG_IDLERESCHED,
- "idle reschedule"),
- timer);
- post_event = ISC_FALSE;
- need_schedule = ISC_TRUE;
+ idle = ISC_FALSE;
+
+ LOCK(&timer->lock);
+ if (!isc_time_isepoch(&timer->idle) &&
+ isc_time_compare(now,
+ &timer->idle) >= 0) {
+ idle = ISC_TRUE;
+ }
+ UNLOCK(&timer->lock);
+ if (idle) {
+ type = ISC_TIMEREVENT_IDLE;
+ post_event = ISC_TRUE;
+ need_schedule = ISC_FALSE;
+ } else {
+ /*
+ * Idle timer has been touched;
+ * reschedule.
+ */
+ XTRACEID(isc_msgcat_get(isc_msgcat,
+ ISC_MSGSET_TIMER,
+ ISC_MSG_IDLERESCHED,
+ "idle reschedule"),
+ timer);
+ post_event = ISC_FALSE;
+ need_schedule = ISC_TRUE;
+ }
}
if (post_event) {