mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +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.
|
||||
*
|
||||
* 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
|
||||
* can be idle before it generates an idle timeout. If 0, then no
|
||||
* 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:
|
||||
*
|
||||
* 'manager' is a valid manager
|
||||
@@ -143,8 +147,12 @@ isc_timer_create(isc_timermgr_t *manager,
|
||||
*
|
||||
* 'action' is a valid action
|
||||
*
|
||||
* (type == isc_timertype_inactive && expires == NULL && interval == NULL)
|
||||
* || ('expires' and 'interval' are not both 0)
|
||||
* 'expires' points to a valid time, or is NULL.
|
||||
*
|
||||
* '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
|
||||
*
|
||||
@@ -175,7 +183,13 @@ isc_timer_reset(isc_timer_t *timer,
|
||||
* Change the timer's type, expires, and interval values to the given
|
||||
* values. If 'purge' is TRUE, any pending events from this timer
|
||||
* 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:
|
||||
*
|
||||
* '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(task != NULL);
|
||||
REQUIRE(action != NULL);
|
||||
REQUIRE((type == isc_timertype_inactive &&
|
||||
expires == NULL && interval == NULL) ||
|
||||
if (expires == 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)));
|
||||
REQUIRE(timerp != NULL && *timerp == NULL);
|
||||
|
||||
/*
|
||||
* Get current time.
|
||||
*/
|
||||
result = isc_time_get(&now);
|
||||
result = isc_time_now(&now);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_time_get() failed: %s",
|
||||
"isc_time_now() failed: %s",
|
||||
isc_result_totext(result));
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
@@ -326,17 +329,20 @@ isc_timer_reset(isc_timer_t *timer, isc_timertype_t type,
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
manager = timer->manager;
|
||||
REQUIRE(VALID_MANAGER(manager));
|
||||
REQUIRE((type == isc_timertype_inactive &&
|
||||
expires == NULL && interval == NULL) ||
|
||||
if (expires == 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)));
|
||||
|
||||
/*
|
||||
* Get current time.
|
||||
*/
|
||||
result = isc_time_get(&now);
|
||||
result = isc_time_now(&now);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_time_get() failed: %s",
|
||||
"isc_time_now() failed: %s",
|
||||
isc_result_totext(result));
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
@@ -392,10 +398,10 @@ isc_timer_touch(isc_timer_t *timer) {
|
||||
* don't want to do.
|
||||
*/
|
||||
|
||||
result = isc_time_get(&now);
|
||||
result = isc_time_now(&now);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_time_get() failed: %s",
|
||||
"isc_time_now() failed: %s",
|
||||
isc_result_totext(result));
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
@@ -537,7 +543,7 @@ run(void *uap) {
|
||||
|
||||
LOCK(&manager->lock);
|
||||
while (!manager->done) {
|
||||
RUNTIME_CHECK(isc_time_get(&now) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_time_now(&now) == ISC_R_SUCCESS);
|
||||
|
||||
XTRACETIME("running", now);
|
||||
|
||||
|
Reference in New Issue
Block a user