mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Timers now use isc_time_t rather than isc_stdtime_t.
zone->expiretime now has a consistant epoch [RT #1686]
This commit is contained in:
218
lib/dns/zone.c
218
lib/dns/zone.c
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: zone.c,v 1.335 2001/08/30 06:48:43 marka Exp $ */
|
/* $Id: zone.c,v 1.336 2001/08/31 02:01:56 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -148,9 +148,9 @@ struct dns_zone {
|
|||||||
unsigned int options;
|
unsigned int options;
|
||||||
unsigned int db_argc;
|
unsigned int db_argc;
|
||||||
char **db_argv;
|
char **db_argv;
|
||||||
isc_stdtime_t expiretime;
|
isc_time_t expiretime;
|
||||||
isc_stdtime_t refreshtime;
|
isc_time_t refreshtime;
|
||||||
isc_stdtime_t dumptime;
|
isc_time_t dumptime;
|
||||||
isc_time_t loadtime;
|
isc_time_t loadtime;
|
||||||
isc_uint32_t serial;
|
isc_uint32_t serial;
|
||||||
isc_uint32_t refresh;
|
isc_uint32_t refresh;
|
||||||
@@ -361,7 +361,7 @@ struct dns_io {
|
|||||||
isc_event_t *event;
|
isc_event_t *event;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void zone_settimer(dns_zone_t *, isc_stdtime_t);
|
static void zone_settimer(dns_zone_t *, isc_time_t *);
|
||||||
static void cancel_refresh(dns_zone_t *);
|
static void cancel_refresh(dns_zone_t *);
|
||||||
static void zone_debuglog(dns_zone_t *zone, const char *, int debuglevel,
|
static void zone_debuglog(dns_zone_t *zone, const char *, int debuglevel,
|
||||||
const char *msg, ...) ISC_FORMAT_PRINTF(4, 5);
|
const char *msg, ...) ISC_FORMAT_PRINTF(4, 5);
|
||||||
@@ -481,9 +481,9 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
|||||||
zone->options = 0;
|
zone->options = 0;
|
||||||
zone->db_argc = 0;
|
zone->db_argc = 0;
|
||||||
zone->db_argv = NULL;
|
zone->db_argv = NULL;
|
||||||
zone->expiretime = 0;
|
isc_time_settoepoch(&zone->expiretime);
|
||||||
zone->refreshtime = 0;
|
isc_time_settoepoch(&zone->refreshtime);
|
||||||
zone->dumptime = 0;
|
isc_time_settoepoch(&zone->dumptime);
|
||||||
isc_time_settoepoch(&zone->loadtime);
|
isc_time_settoepoch(&zone->loadtime);
|
||||||
zone->serial = 0;
|
zone->serial = 0;
|
||||||
zone->refresh = DNS_ZONE_DEFAULTREFRESH;
|
zone->refresh = DNS_ZONE_DEFAULTREFRESH;
|
||||||
@@ -885,14 +885,14 @@ zone_isdynamic(dns_zone_t *zone) {
|
|||||||
static isc_result_t
|
static isc_result_t
|
||||||
zone_load(dns_zone_t *zone, unsigned int flags) {
|
zone_load(dns_zone_t *zone, unsigned int flags) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
isc_time_t loadtime, filetime;
|
isc_time_t loadtime, filetime;
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
|
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
|
|
||||||
LOCK_ZONE(zone);
|
LOCK_ZONE(zone);
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
|
|
||||||
INSIST(zone->type != dns_zone_none);
|
INSIST(zone->type != dns_zone_none);
|
||||||
|
|
||||||
@@ -1122,10 +1122,10 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
|
|||||||
unsigned int soacount = 0;
|
unsigned int soacount = 0;
|
||||||
unsigned int nscount = 0;
|
unsigned int nscount = 0;
|
||||||
isc_uint32_t serial, refresh, retry, expire, minimum;
|
isc_uint32_t serial, refresh, retry, expire, minimum;
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
isc_boolean_t needdump = ISC_FALSE;
|
isc_boolean_t needdump = ISC_FALSE;
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initiate zone transfer? We may need a error code that
|
* Initiate zone transfer? We may need a error code that
|
||||||
@@ -1244,17 +1244,20 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
|
|||||||
if (zone->type == dns_zone_slave ||
|
if (zone->type == dns_zone_slave ||
|
||||||
zone->type == dns_zone_stub) {
|
zone->type == dns_zone_stub) {
|
||||||
isc_time_t t;
|
isc_time_t t;
|
||||||
|
isc_interval_t i;
|
||||||
|
|
||||||
result = isc_file_getmodtime(zone->journal, &t);
|
result = isc_file_getmodtime(zone->journal, &t);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
result = isc_file_getmodtime(zone->masterfile,
|
result = isc_file_getmodtime(zone->masterfile,
|
||||||
&t);
|
&t);
|
||||||
|
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result == ISC_R_SUCCESS) {
|
||||||
zone->expiretime = isc_time_seconds(&t) +
|
isc_interval_set(&i, zone->expire, 0);
|
||||||
zone->expire;
|
isc_time_add(&t, &i, &zone->expiretime);
|
||||||
else
|
} else {
|
||||||
zone->expiretime = now + zone->retry;
|
isc_interval_set(&i, zone->retry, 0);
|
||||||
|
isc_time_add(&now, &i, &zone->expiretime);
|
||||||
|
}
|
||||||
zone->refreshtime = now;
|
zone->refreshtime = now;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1291,7 +1294,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
|
|||||||
if (needdump)
|
if (needdump)
|
||||||
zone_needdump(zone, DNS_DUMP_DELAY);
|
zone_needdump(zone, DNS_DUMP_DELAY);
|
||||||
if (zone->task != NULL)
|
if (zone->task != NULL)
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
dns_zone_log(zone, ISC_LOG_INFO, "loaded serial %u", zone->serial);
|
dns_zone_log(zone, ISC_LOG_INFO, "loaded serial %u", zone->serial);
|
||||||
return (result);
|
return (result);
|
||||||
|
|
||||||
@@ -1871,14 +1874,14 @@ dns_zone_getdb(dns_zone_t *zone, dns_db_t **dpb) {
|
|||||||
void
|
void
|
||||||
dns_zone_maintenance(dns_zone_t *zone) {
|
dns_zone_maintenance(dns_zone_t *zone) {
|
||||||
const char me[] = "dns_zone_maintenance";
|
const char me[] = "dns_zone_maintenance";
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
|
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
ENTER;
|
ENTER;
|
||||||
|
|
||||||
LOCK_ZONE(zone);
|
LOCK_ZONE(zone);
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1892,7 +1895,7 @@ was_dumping(dns_zone_t *zone) {
|
|||||||
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_DUMPING);
|
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_DUMPING);
|
||||||
if (!dumping) {
|
if (!dumping) {
|
||||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
|
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
|
||||||
zone->dumptime = 0;
|
isc_time_settoepoch(&zone->dumptime);
|
||||||
}
|
}
|
||||||
return (dumping);
|
return (dumping);
|
||||||
}
|
}
|
||||||
@@ -1900,7 +1903,7 @@ was_dumping(dns_zone_t *zone) {
|
|||||||
static void
|
static void
|
||||||
zone_maintenance(dns_zone_t *zone) {
|
zone_maintenance(dns_zone_t *zone) {
|
||||||
const char me[] = "zone_maintenance";
|
const char me[] = "zone_maintenance";
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_boolean_t dumping;
|
isc_boolean_t dumping;
|
||||||
|
|
||||||
@@ -1917,7 +1920,7 @@ zone_maintenance(dns_zone_t *zone) {
|
|||||||
if (zone->view == NULL || zone->view->adb == NULL)
|
if (zone->view == NULL || zone->view->adb == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Expire check.
|
* Expire check.
|
||||||
@@ -1926,7 +1929,7 @@ zone_maintenance(dns_zone_t *zone) {
|
|||||||
case dns_zone_slave:
|
case dns_zone_slave:
|
||||||
case dns_zone_stub:
|
case dns_zone_stub:
|
||||||
LOCK_ZONE(zone);
|
LOCK_ZONE(zone);
|
||||||
if (now >= zone->expiretime &&
|
if (isc_time_compare(&now, &zone->expiretime) >= 0 &&
|
||||||
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
|
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
|
||||||
zone_expire(zone);
|
zone_expire(zone);
|
||||||
zone->refreshtime = now;
|
zone->refreshtime = now;
|
||||||
@@ -1944,7 +1947,7 @@ zone_maintenance(dns_zone_t *zone) {
|
|||||||
case dns_zone_slave:
|
case dns_zone_slave:
|
||||||
case dns_zone_stub:
|
case dns_zone_stub:
|
||||||
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DIALREFRESH) &&
|
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DIALREFRESH) &&
|
||||||
now >= zone->refreshtime)
|
isc_time_compare(&now, &zone->refreshtime) >= 0)
|
||||||
dns_zone_refresh(zone);
|
dns_zone_refresh(zone);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1959,7 +1962,7 @@ zone_maintenance(dns_zone_t *zone) {
|
|||||||
case dns_zone_slave:
|
case dns_zone_slave:
|
||||||
LOCK_ZONE(zone);
|
LOCK_ZONE(zone);
|
||||||
if (zone->masterfile != NULL &&
|
if (zone->masterfile != NULL &&
|
||||||
now >= zone->dumptime &&
|
isc_time_compare(&now, &zone->dumptime) >= 0 &&
|
||||||
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED) &&
|
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED) &&
|
||||||
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP)) {
|
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP)) {
|
||||||
dumping = was_dumping(zone);
|
dumping = was_dumping(zone);
|
||||||
@@ -1990,7 +1993,7 @@ zone_maintenance(dns_zone_t *zone) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2030,7 +2033,7 @@ zone_expire(dns_zone_t *zone) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
dns_zone_refresh(dns_zone_t *zone) {
|
dns_zone_refresh(dns_zone_t *zone) {
|
||||||
isc_stdtime_t now;
|
isc_interval_t i;
|
||||||
isc_uint32_t oldflags;
|
isc_uint32_t oldflags;
|
||||||
|
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
@@ -2038,8 +2041,6 @@ dns_zone_refresh(dns_zone_t *zone) {
|
|||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set DNS_ZONEFLG_REFRESH so that there is only one refresh operation
|
* Set DNS_ZONEFLG_REFRESH so that there is only one refresh operation
|
||||||
* in progress at a time.
|
* in progress at a time.
|
||||||
@@ -2063,11 +2064,9 @@ dns_zone_refresh(dns_zone_t *zone) {
|
|||||||
* Setting this to the retry time will do that. XXXMLG
|
* Setting this to the retry time will do that. XXXMLG
|
||||||
* If we are successful it will be reset using zone->refresh.
|
* If we are successful it will be reset using zone->refresh.
|
||||||
*/
|
*/
|
||||||
zone->refreshtime = now +
|
isc_interval_set(&i, isc_random_jitter(zone->retry, zone->retry / 4),
|
||||||
isc_random_jitter(zone->retry, zone->retry / 4);
|
0);
|
||||||
zone_debuglog(zone, "dns_zone_refresh", 20,
|
isc_time_nowplusinterval(&zone->refreshtime, &i);
|
||||||
"refresh time (%u/%u), now %u",
|
|
||||||
zone->refreshtime, zone->refresh, now);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When lacking user-specified timer values from the SOA,
|
* When lacking user-specified timer values from the SOA,
|
||||||
@@ -2122,7 +2121,9 @@ dns_zone_dump(dns_zone_t *zone) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
zone_needdump(dns_zone_t *zone, unsigned int delay) {
|
zone_needdump(dns_zone_t *zone, unsigned int delay) {
|
||||||
isc_stdtime_t now;
|
isc_time_t dumptime;
|
||||||
|
isc_time_t now;
|
||||||
|
isc_interval_t i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'zone' locked by caller
|
* 'zone' locked by caller
|
||||||
@@ -2138,16 +2139,18 @@ zone_needdump(dns_zone_t *zone, unsigned int delay) {
|
|||||||
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED) == 0)
|
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_interval_set(&i, delay, 0);
|
||||||
|
isc_time_now(&now);
|
||||||
|
isc_time_add(&now, &i, &dumptime);
|
||||||
|
|
||||||
/* add some noise */
|
/* add some noise */
|
||||||
delay = isc_random_jitter(delay, delay/4);
|
delay = isc_random_jitter(delay, delay/4);
|
||||||
|
|
||||||
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
|
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
|
||||||
if (zone->dumptime == 0 ||
|
if (isc_time_isepoch(&zone->dumptime) ||
|
||||||
zone->dumptime > now + delay)
|
isc_time_compare(&zone->dumptime, &dumptime) > 0)
|
||||||
zone->dumptime = now + delay;
|
zone->dumptime = dumptime;
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
@@ -2234,7 +2237,7 @@ zone_dump(dns_zone_t *zone, isc_boolean_t compact) {
|
|||||||
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
|
DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
|
||||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
|
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
|
||||||
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_DUMPING);
|
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_DUMPING);
|
||||||
zone->dumptime = 0;
|
isc_time_settoepoch(&zone->dumptime);
|
||||||
again = ISC_TRUE;
|
again = ISC_TRUE;
|
||||||
}
|
}
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
@@ -2615,15 +2618,15 @@ notify_send(dns_notify_t *notify) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
dns_zone_notify(dns_zone_t *zone) {
|
dns_zone_notify(dns_zone_t *zone) {
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
|
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
|
|
||||||
LOCK_ZONE(zone);
|
LOCK_ZONE(zone);
|
||||||
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
|
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2916,8 +2919,9 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
char master[ISC_SOCKADDR_FORMATSIZE];
|
char master[ISC_SOCKADDR_FORMATSIZE];
|
||||||
isc_uint32_t nscnt, cnamecnt;
|
isc_uint32_t nscnt, cnamecnt;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
isc_boolean_t exiting = ISC_FALSE;
|
isc_boolean_t exiting = ISC_FALSE;
|
||||||
|
isc_interval_t i;
|
||||||
|
|
||||||
stub = revent->ev_arg;
|
stub = revent->ev_arg;
|
||||||
INSIST(DNS_STUB_VALID(stub));
|
INSIST(DNS_STUB_VALID(stub));
|
||||||
@@ -2928,7 +2932,7 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
|
|
||||||
ENTER;
|
ENTER;
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
|
|
||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
|
||||||
zone_debuglog(zone, me, 1, "exiting");
|
zone_debuglog(zone, me, 1, "exiting");
|
||||||
@@ -3048,13 +3052,12 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
LOCK_ZONE(zone);
|
LOCK_ZONE(zone);
|
||||||
dns_request_destroy(&zone->request);
|
dns_request_destroy(&zone->request);
|
||||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
|
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
|
||||||
zone->refreshtime = now +
|
isc_interval_set(&i, isc_random_jitter(zone->refresh,
|
||||||
isc_random_jitter(zone->refresh, zone->refresh / 4);
|
zone->refresh / 4), 0);
|
||||||
zone->expiretime = now + zone->expire;
|
isc_time_add(&now, &i, &zone->refreshtime);
|
||||||
zone_debuglog(zone, me, 20,
|
isc_interval_set(&i, zone->expire, 0);
|
||||||
"refresh time (%u/%u), now %u",
|
isc_time_add(&now, &i, &zone->expiretime);
|
||||||
zone->refreshtime, zone->refresh, now);
|
zone_settimer(zone, &now);
|
||||||
zone_settimer(zone, now);
|
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
goto free_stub;
|
goto free_stub;
|
||||||
|
|
||||||
@@ -3073,7 +3076,7 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
if (exiting || zone->curmaster >= zone->masterscnt) {
|
if (exiting || zone->curmaster >= zone->masterscnt) {
|
||||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
|
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
|
||||||
|
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
goto free_stub;
|
goto free_stub;
|
||||||
}
|
}
|
||||||
@@ -3113,13 +3116,14 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
dns_zone_t *zone;
|
dns_zone_t *zone;
|
||||||
dns_message_t *msg = NULL;
|
dns_message_t *msg = NULL;
|
||||||
isc_uint32_t soacnt, cnamecnt, soacount, nscount;
|
isc_uint32_t soacnt, cnamecnt, soacount, nscount;
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
char master[ISC_SOCKADDR_FORMATSIZE];
|
char master[ISC_SOCKADDR_FORMATSIZE];
|
||||||
dns_rdataset_t *rdataset;
|
dns_rdataset_t *rdataset;
|
||||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||||
dns_rdata_soa_t soa;
|
dns_rdata_soa_t soa;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_uint32_t serial;
|
isc_uint32_t serial;
|
||||||
|
isc_interval_t i;
|
||||||
|
|
||||||
zone = revent->ev_arg;
|
zone = revent->ev_arg;
|
||||||
INSIST(DNS_ZONE_VALID(zone));
|
INSIST(DNS_ZONE_VALID(zone));
|
||||||
@@ -3134,7 +3138,7 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
|
|
||||||
isc_sockaddr_format(&zone->masteraddr, master, sizeof(master));
|
isc_sockaddr_format(&zone->masteraddr, master, sizeof(master));
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
|
|
||||||
if (revent->result != ISC_R_SUCCESS) {
|
if (revent->result != ISC_R_SUCCESS) {
|
||||||
dns_zone_log(zone, ISC_LOG_INFO,
|
dns_zone_log(zone, ISC_LOG_INFO,
|
||||||
@@ -3313,9 +3317,7 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
dns_message_destroy(&msg);
|
dns_message_destroy(&msg);
|
||||||
} else if (isc_serial_eq(soa.serial, zone->serial)) {
|
} else if (isc_serial_eq(soa.serial, zone->serial)) {
|
||||||
if (zone->masterfile != NULL) {
|
if (zone->masterfile != NULL) {
|
||||||
isc_time_t t;
|
result = isc_file_settime(zone->masterfile, &now);
|
||||||
(void)isc_time_now(&t);
|
|
||||||
result = isc_file_settime(zone->masterfile, &t);
|
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
dns_zone_log(zone, ISC_LOG_ERROR,
|
dns_zone_log(zone, ISC_LOG_ERROR,
|
||||||
"refresh: could not set file "
|
"refresh: could not set file "
|
||||||
@@ -3323,12 +3325,11 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
zone->masterfile,
|
zone->masterfile,
|
||||||
dns_result_totext(result));
|
dns_result_totext(result));
|
||||||
}
|
}
|
||||||
zone->refreshtime = now +
|
isc_interval_set(&i, isc_random_jitter(zone->refresh,
|
||||||
isc_random_jitter(zone->refresh, zone->refresh / 4);
|
zone->refresh / 4), 0);
|
||||||
zone->expiretime = now + zone->expire;
|
isc_time_add(&now, &i, &zone->refreshtime);
|
||||||
zone_debuglog(zone, me, 20, "refresh time (%u/%u), now %u",
|
isc_interval_set(&i, zone->expire, 0);
|
||||||
zone->refreshtime, zone->refresh, now);
|
isc_time_add(&now, &i, &zone->expiretime);
|
||||||
|
|
||||||
goto next_master;
|
goto next_master;
|
||||||
} else {
|
} else {
|
||||||
zone_debuglog(zone, me, 1, "ahead");
|
zone_debuglog(zone, me, 1, "ahead");
|
||||||
@@ -3352,7 +3353,7 @@ refresh_callback(isc_task_t *task, isc_event_t *event) {
|
|||||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDREFRESH);
|
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDREFRESH);
|
||||||
zone->refreshtime = now;
|
zone->refreshtime = now;
|
||||||
}
|
}
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
goto detach;
|
goto detach;
|
||||||
}
|
}
|
||||||
@@ -3792,9 +3793,9 @@ zone_timer(isc_task_t *task, isc_event_t *event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zone_settimer(dns_zone_t *zone, isc_stdtime_t now) {
|
zone_settimer(dns_zone_t *zone, isc_time_t *now) {
|
||||||
const char me[] = "zone_settimer";
|
const char me[] = "zone_settimer";
|
||||||
isc_stdtime_t next = 0;
|
isc_time_t next;
|
||||||
isc_time_t expires;
|
isc_time_t expires;
|
||||||
isc_interval_t interval;
|
isc_interval_t interval;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
@@ -3803,21 +3804,24 @@ zone_settimer(dns_zone_t *zone, isc_stdtime_t now) {
|
|||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
isc_time_settoepoch(&next);
|
||||||
|
|
||||||
switch (zone->type) {
|
switch (zone->type) {
|
||||||
case dns_zone_master:
|
case dns_zone_master:
|
||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDNOTIFY))
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDNOTIFY))
|
||||||
next = now;
|
next = *now;
|
||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP) &&
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDDUMP) &&
|
||||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DUMPING)) {
|
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DUMPING)) {
|
||||||
INSIST(zone->dumptime != 0);
|
INSIST(!isc_time_isepoch(&zone->dumptime));
|
||||||
if (zone->dumptime < next || next == 0)
|
if (isc_time_compare(&zone->dumptime, &next) < 0 ||
|
||||||
|
isc_time_isepoch(&next))
|
||||||
next = zone->dumptime;
|
next = zone->dumptime;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case dns_zone_slave:
|
case dns_zone_slave:
|
||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDNOTIFY))
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDNOTIFY))
|
||||||
next = now;
|
next = *now;
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
|
|
||||||
case dns_zone_stub:
|
case dns_zone_stub:
|
||||||
@@ -3825,13 +3829,15 @@ zone_settimer(dns_zone_t *zone, isc_stdtime_t now) {
|
|||||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOMASTERS) &&
|
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOMASTERS) &&
|
||||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOREFRESH) &&
|
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOREFRESH) &&
|
||||||
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADING)) {
|
!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADING)) {
|
||||||
INSIST(zone->refreshtime != 0);
|
INSIST(!isc_time_isepoch(&zone->refreshtime));
|
||||||
if (zone->refreshtime < next || next == 0)
|
if (isc_time_compare(&zone->refreshtime, &next) < 0 ||
|
||||||
|
isc_time_isepoch(&next))
|
||||||
next = zone->refreshtime;
|
next = zone->refreshtime;
|
||||||
}
|
}
|
||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
|
||||||
INSIST(zone->expiretime != 0);
|
INSIST(!isc_time_isepoch(&zone->expiretime));
|
||||||
if (zone->expiretime < next || next == 0)
|
if (isc_time_compare(&zone->expiretime, &next) < 0 ||
|
||||||
|
isc_time_isepoch(&next))
|
||||||
next = zone->expiretime;
|
next = zone->expiretime;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3840,7 +3846,7 @@ zone_settimer(dns_zone_t *zone, isc_stdtime_t now) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next == 0) {
|
if (isc_time_isepoch(&next)) {
|
||||||
zone_debuglog(zone, me, 10, "settimer inactive");
|
zone_debuglog(zone, me, 10, "settimer inactive");
|
||||||
result = isc_timer_reset(zone->timer, isc_timertype_inactive,
|
result = isc_timer_reset(zone->timer, isc_timertype_inactive,
|
||||||
NULL, NULL, ISC_TRUE);
|
NULL, NULL, ISC_TRUE);
|
||||||
@@ -3849,16 +3855,15 @@ zone_settimer(dns_zone_t *zone, isc_stdtime_t now) {
|
|||||||
"could not deactivate zone timer: %s",
|
"could not deactivate zone timer: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
} else {
|
} else {
|
||||||
if (next <= now) {
|
if (isc_time_compare(&next, now) <= 0) {
|
||||||
next = now;
|
expires = *now;
|
||||||
(void)isc_time_now(&expires);
|
|
||||||
isc_interval_set(&interval, 0, 0);
|
isc_interval_set(&interval, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
int s;
|
||||||
isc_time_settoepoch(&expires);
|
isc_time_settoepoch(&expires);
|
||||||
isc_interval_set(&interval, next - now, 0);
|
s = isc_time_microdiff(&next, now) / 1000000;
|
||||||
|
isc_interval_set(&interval, s, 0);
|
||||||
}
|
}
|
||||||
zone_debuglog(zone, me, 10, "settimer %d %d = %d seconds",
|
|
||||||
next, now, next - now);
|
|
||||||
result = isc_timer_reset(zone->timer, isc_timertype_once,
|
result = isc_timer_reset(zone->timer, isc_timertype_once,
|
||||||
&expires, &interval, ISC_TRUE);
|
&expires, &interval, ISC_TRUE);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
@@ -3871,7 +3876,7 @@ zone_settimer(dns_zone_t *zone, isc_stdtime_t now) {
|
|||||||
static void
|
static void
|
||||||
cancel_refresh(dns_zone_t *zone) {
|
cancel_refresh(dns_zone_t *zone) {
|
||||||
const char me[] = "cancel_refresh";
|
const char me[] = "cancel_refresh";
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'zone' locked by caller.
|
* 'zone' locked by caller.
|
||||||
@@ -3883,8 +3888,8 @@ cancel_refresh(dns_zone_t *zone) {
|
|||||||
ENTER;
|
ENTER;
|
||||||
|
|
||||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
|
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
@@ -4043,7 +4048,7 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
|
|||||||
dns_rdataset_t *rdataset = NULL;
|
dns_rdataset_t *rdataset = NULL;
|
||||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_stdtime_t now;
|
isc_time_t now;
|
||||||
char fromtext[ISC_SOCKADDR_FORMATSIZE];
|
char fromtext[ISC_SOCKADDR_FORMATSIZE];
|
||||||
int match = 0;
|
int match = 0;
|
||||||
isc_netaddr_t netaddr;
|
isc_netaddr_t netaddr;
|
||||||
@@ -4173,7 +4178,7 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
|
|||||||
fromtext);
|
fromtext);
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
zone->notifyfrom = *from;
|
zone->notifyfrom = *from;
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
dns_zone_refresh(zone);
|
dns_zone_refresh(zone);
|
||||||
@@ -4714,8 +4719,8 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, isc_boolean_t dump) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
|
zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
|
||||||
const char me[] = "zone_xfrdone";
|
isc_time_t now;
|
||||||
isc_stdtime_t now;
|
isc_interval_t i;
|
||||||
isc_boolean_t again = ISC_FALSE;
|
isc_boolean_t again = ISC_FALSE;
|
||||||
unsigned int soacount;
|
unsigned int soacount;
|
||||||
unsigned int nscount;
|
unsigned int nscount;
|
||||||
@@ -4731,7 +4736,7 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
|
|||||||
INSIST((zone->flags & DNS_ZONEFLG_REFRESH) != 0);
|
INSIST((zone->flags & DNS_ZONEFLG_REFRESH) != 0);
|
||||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
|
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESH);
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_time_now(&now);
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case ISC_R_SUCCESS:
|
case ISC_R_SUCCESS:
|
||||||
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
|
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
|
||||||
@@ -4749,16 +4754,13 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
|
|||||||
* won't hurt with an AXFR.
|
* won't hurt with an AXFR.
|
||||||
*/
|
*/
|
||||||
if (zone->masterfile != NULL || zone->journal != NULL) {
|
if (zone->masterfile != NULL || zone->journal != NULL) {
|
||||||
isc_time_t t;
|
|
||||||
|
|
||||||
(void)isc_time_now(&t);
|
|
||||||
|
|
||||||
result = ISC_R_FAILURE;
|
result = ISC_R_FAILURE;
|
||||||
if (zone->journal != NULL)
|
if (zone->journal != NULL)
|
||||||
result = isc_file_settime(zone->journal, &t);
|
result = isc_file_settime(zone->journal, &now);
|
||||||
if (result != ISC_R_SUCCESS &&
|
if (result != ISC_R_SUCCESS &&
|
||||||
zone->masterfile != NULL)
|
zone->masterfile != NULL)
|
||||||
result = isc_file_settime(zone->masterfile, &t);
|
result = isc_file_settime(zone->masterfile,
|
||||||
|
&now);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
dns_zone_log(zone, ISC_LOG_ERROR,
|
dns_zone_log(zone, ISC_LOG_ERROR,
|
||||||
"transfer: could not set file "
|
"transfer: could not set file "
|
||||||
@@ -4805,16 +4807,14 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
|
|||||||
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDREFRESH)) {
|
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NEEDREFRESH)) {
|
||||||
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDREFRESH);
|
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDREFRESH);
|
||||||
zone->refreshtime = now;
|
zone->refreshtime = now;
|
||||||
zone->expiretime = now + zone->expire;
|
isc_interval_set(&i, zone->expire, 0);
|
||||||
|
isc_time_add(&now, &i, &zone->expiretime);
|
||||||
} else {
|
} else {
|
||||||
zone->refreshtime = now +
|
isc_interval_set(&i, isc_random_jitter(zone->refresh,
|
||||||
isc_random_jitter(zone->refresh,
|
zone->refresh / 4), 0);
|
||||||
zone->refresh / 4);
|
isc_time_add(&now, &i, &zone->refreshtime);
|
||||||
zone_debuglog(zone, me, 20,
|
isc_interval_set(&i, zone->expire, 0);
|
||||||
"refresh time (%u/%u), now %u",
|
isc_time_add(&now, &i, &zone->expiretime);
|
||||||
zone->refreshtime, zone->refresh, now);
|
|
||||||
|
|
||||||
zone->expiretime = now + zone->expire;
|
|
||||||
}
|
}
|
||||||
if (result == ISC_R_SUCCESS && xfrresult == ISC_R_SUCCESS)
|
if (result == ISC_R_SUCCESS && xfrresult == ISC_R_SUCCESS)
|
||||||
dns_zone_log(zone, ISC_LOG_INFO,
|
dns_zone_log(zone, ISC_LOG_INFO,
|
||||||
@@ -4838,7 +4838,7 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
zone_settimer(zone, now);
|
zone_settimer(zone, &now);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If creating the transfer object failed, zone->xfr is NULL.
|
* If creating the transfer object failed, zone->xfr is NULL.
|
||||||
|
Reference in New Issue
Block a user