mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
use isc_time_now; allow default expires and interval
This commit is contained in:
@@ -130,11 +130,15 @@ isc_timer_create(isc_timermgr_t *manager,
|
|||||||
* 'interval' seconds. The value of 'expires' is ignored.
|
* 'interval' seconds. The value of 'expires' is ignored.
|
||||||
*
|
*
|
||||||
* For once timers, 'expires' specifies the time when a life timeout
|
* For once timers, 'expires' specifies the time when a life timeout
|
||||||
* event should be generated. If 'expires' is 0, then no life
|
* event should be generated. If 'expires' is 0 (the epoch), then no life
|
||||||
* timeout will be generated. 'interval' specifies how long the timer
|
* timeout will be generated. 'interval' specifies how long the timer
|
||||||
* can be idle before it generates an idle timeout. If 0, then no
|
* can be idle before it generates an idle timeout. If 0, then no
|
||||||
* idle timeout will be generated.
|
* idle timeout will be generated.
|
||||||
*
|
*
|
||||||
|
* If 'expires' is NULL, the epoch will be used.
|
||||||
|
*
|
||||||
|
* If 'interval' is NULL, the zero interval will be used.
|
||||||
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
*
|
*
|
||||||
* 'manager' is a valid manager
|
* 'manager' is a valid manager
|
||||||
@@ -143,8 +147,12 @@ isc_timer_create(isc_timermgr_t *manager,
|
|||||||
*
|
*
|
||||||
* 'action' is a valid action
|
* 'action' is a valid action
|
||||||
*
|
*
|
||||||
* (type == isc_timertype_inactive && expires == NULL && interval == NULL)
|
* 'expires' points to a valid time, or is NULL.
|
||||||
* || ('expires' and 'interval' are not both 0)
|
*
|
||||||
|
* 'interval' points to a valid interval, or is NULL.
|
||||||
|
*
|
||||||
|
* type == isc_timertype_inactive ||
|
||||||
|
* ('expires' and 'interval' are not both 0)
|
||||||
*
|
*
|
||||||
* 'timerp' is a valid pointer, and *timerp == NULL
|
* 'timerp' is a valid pointer, and *timerp == NULL
|
||||||
*
|
*
|
||||||
@@ -175,7 +183,13 @@ isc_timer_reset(isc_timer_t *timer,
|
|||||||
* Change the timer's type, expires, and interval values to the given
|
* Change the timer's type, expires, and interval values to the given
|
||||||
* values. If 'purge' is TRUE, any pending events from this timer
|
* values. If 'purge' is TRUE, any pending events from this timer
|
||||||
* are purged from its task's event queue.
|
* are purged from its task's event queue.
|
||||||
*
|
*
|
||||||
|
* Notes:
|
||||||
|
*
|
||||||
|
* If 'expires' is NULL, the epoch will be used.
|
||||||
|
*
|
||||||
|
* If 'interval' is NULL, the zero interval will be used.
|
||||||
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
*
|
*
|
||||||
* 'timer' is a valid timer
|
* 'timer' is a valid timer
|
||||||
|
@@ -234,18 +234,21 @@ isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type,
|
|||||||
REQUIRE(VALID_MANAGER(manager));
|
REQUIRE(VALID_MANAGER(manager));
|
||||||
REQUIRE(task != NULL);
|
REQUIRE(task != NULL);
|
||||||
REQUIRE(action != NULL);
|
REQUIRE(action != NULL);
|
||||||
REQUIRE((type == isc_timertype_inactive &&
|
if (expires == NULL)
|
||||||
expires == NULL && interval == NULL) ||
|
expires = isc_time_epoch;
|
||||||
|
if (interval == NULL)
|
||||||
|
interval = isc_interval_zero;
|
||||||
|
REQUIRE(type == isc_timertype_inactive ||
|
||||||
!(isc_time_isepoch(expires) && isc_interval_iszero(interval)));
|
!(isc_time_isepoch(expires) && isc_interval_iszero(interval)));
|
||||||
REQUIRE(timerp != NULL && *timerp == NULL);
|
REQUIRE(timerp != NULL && *timerp == NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get current time.
|
* Get current time.
|
||||||
*/
|
*/
|
||||||
result = isc_time_get(&now);
|
result = isc_time_now(&now);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"isc_time_get() failed: %s",
|
"isc_time_now() failed: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
@@ -326,17 +329,20 @@ isc_timer_reset(isc_timer_t *timer, isc_timertype_t type,
|
|||||||
REQUIRE(VALID_TIMER(timer));
|
REQUIRE(VALID_TIMER(timer));
|
||||||
manager = timer->manager;
|
manager = timer->manager;
|
||||||
REQUIRE(VALID_MANAGER(manager));
|
REQUIRE(VALID_MANAGER(manager));
|
||||||
REQUIRE((type == isc_timertype_inactive &&
|
if (expires == NULL)
|
||||||
expires == NULL && interval == NULL) ||
|
expires = isc_time_epoch;
|
||||||
|
if (interval == NULL)
|
||||||
|
interval = isc_interval_zero;
|
||||||
|
REQUIRE(type == isc_timertype_inactive ||
|
||||||
!(isc_time_isepoch(expires) && isc_interval_iszero(interval)));
|
!(isc_time_isepoch(expires) && isc_interval_iszero(interval)));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get current time.
|
* Get current time.
|
||||||
*/
|
*/
|
||||||
result = isc_time_get(&now);
|
result = isc_time_now(&now);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"isc_time_get() failed: %s",
|
"isc_time_now() failed: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
@@ -392,10 +398,10 @@ isc_timer_touch(isc_timer_t *timer) {
|
|||||||
* don't want to do.
|
* don't want to do.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result = isc_time_get(&now);
|
result = isc_time_now(&now);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"isc_time_get() failed: %s",
|
"isc_time_now() failed: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
@@ -537,7 +543,7 @@ run(void *uap) {
|
|||||||
|
|
||||||
LOCK(&manager->lock);
|
LOCK(&manager->lock);
|
||||||
while (!manager->done) {
|
while (!manager->done) {
|
||||||
RUNTIME_CHECK(isc_time_get(&now) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_time_now(&now) == ISC_R_SUCCESS);
|
||||||
|
|
||||||
XTRACETIME("running", now);
|
XTRACETIME("running", now);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user