mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-06 01:25:44 +00:00
1058. [func] Limited lifetime ticker timers are now available,
isc_timertype_limited.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
||||
1058. [func] Limited lifetime ticker timers are now available,
|
||||
isc_timertype_limited.
|
||||
|
||||
1057. [bug] Reloading the server after adding a "file" clause
|
||||
to a zone statement could cause the server to
|
||||
crash due to a typo in change 1016.
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: timer.h,v 1.28 2001/01/09 21:57:41 bwelling Exp $ */
|
||||
/* $Id: timer.h,v 1.29 2001/10/18 06:06:13 marka Exp $ */
|
||||
|
||||
#ifndef ISC_TIMER_H
|
||||
#define ISC_TIMER_H 1
|
||||
@@ -38,6 +38,9 @@
|
||||
* They are used to implement both (possibly expiring) idle timers and
|
||||
* 'one-shot' timers.
|
||||
*
|
||||
* 'limited' timers generate a periodic tick event until they reach
|
||||
* their lifetime when they generate a life timeout event.
|
||||
*
|
||||
* 'inactive' timers generate no events.
|
||||
*
|
||||
* Timers can change type. It is typical to create a timer as
|
||||
@@ -87,7 +90,8 @@ ISC_LANG_BEGINDECLS
|
||||
typedef enum {
|
||||
isc_timertype_ticker = 0,
|
||||
isc_timertype_once = 1,
|
||||
isc_timertype_inactive = 2
|
||||
isc_timertype_limited = 2,
|
||||
isc_timertype_inactive = 3
|
||||
} isc_timertype_t;
|
||||
|
||||
typedef struct isc_timerevent {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: timer.c,v 1.64 2001/06/04 19:33:29 tale Exp $ */
|
||||
/* $Id: timer.c,v 1.65 2001/10/18 06:06:12 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -121,10 +121,13 @@ schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) {
|
||||
/*
|
||||
* Compute the new due time.
|
||||
*/
|
||||
if (timer->type == isc_timertype_ticker) {
|
||||
if (timer->type != isc_timertype_once) {
|
||||
result = isc_time_add(now, &timer->interval, &due);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
if (timer->type == isc_timertype_limited &&
|
||||
isc_time_compare(&timer->expires, &due) < 0)
|
||||
due = timer->expires;
|
||||
} else {
|
||||
if (isc_time_isepoch(&timer->idle))
|
||||
due = timer->expires;
|
||||
@@ -274,6 +277,8 @@ isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type,
|
||||
REQUIRE(type == isc_timertype_inactive ||
|
||||
!(isc_time_isepoch(expires) && isc_interval_iszero(interval)));
|
||||
REQUIRE(timerp != NULL && *timerp == NULL);
|
||||
REQUIRE(type != isc_timertype_limited ||
|
||||
!(isc_time_isepoch(expires) || isc_interval_iszero(interval)));
|
||||
|
||||
/*
|
||||
* Get current time.
|
||||
@@ -397,6 +402,8 @@ isc_timer_reset(isc_timer_t *timer, isc_timertype_t type,
|
||||
interval = isc_interval_zero;
|
||||
REQUIRE(type == isc_timertype_inactive ||
|
||||
!(isc_time_isepoch(expires) && isc_interval_iszero(interval)));
|
||||
REQUIRE(type != isc_timertype_limited ||
|
||||
!(isc_time_isepoch(expires) || isc_interval_iszero(interval)));
|
||||
|
||||
/*
|
||||
* Get current time.
|
||||
@@ -557,6 +564,18 @@ dispatch(isc_timermgr_t *manager, isc_time_t *now) {
|
||||
type = ISC_TIMEREVENT_TICK;
|
||||
post_event = ISC_TRUE;
|
||||
need_schedule = ISC_TRUE;
|
||||
} else if (timer->type == isc_timertype_limited) {
|
||||
int cmp;
|
||||
cmp = isc_time_compare(now, &timer->expires);
|
||||
if (cmp >= 0) {
|
||||
type = ISC_TIMEREVENT_LIFE;
|
||||
post_event = ISC_TRUE;
|
||||
need_schedule = ISC_FALSE;
|
||||
} else {
|
||||
type = ISC_TIMEREVENT_TICK;
|
||||
post_event = ISC_TRUE;
|
||||
need_schedule = ISC_TRUE;
|
||||
}
|
||||
} else if (!isc_time_isepoch(&timer->expires) &&
|
||||
isc_time_compare(now,
|
||||
&timer->expires) >= 0) {
|
||||
|
Reference in New Issue
Block a user