if (ret != KNOT_EOK) {
log_zone_error(zone->name, "failed to load from database (%s)",
ret == KNOT_ERDB ? err : knot_strerror(ret));
+
+ time_t next = time(NULL);
+ const knot_rdataset_t *soa = zone_soa(zone);
+ if (soa != NULL) {
+ next += knot_soa_retry(soa->rdata);
+ } else {
+ next += zone_bootstrap_next(&zone->zonefile.bootstrap_cnt);
+ }
+ zone_events_schedule_at(zone, ZONE_EVENT_LOAD, next);
goto cleanup;
}
zone->zonefile.serial = zone_contents_serial(zf_conts); // for logging
zone->zonefile.serial = zone_contents_serial(zf_conts);
zone->zonefile.exists = (zf_conts != NULL);
zone->zonefile.mtime = mtime;
+ zone->zonefile.bootstrap_cnt = 0;
zonefile_loaded:
// If configured, add reverse records to zone contents
return (serial_compare(local_serial, remote_serial) & SERIAL_MASK_GEQ);
}
-static time_t bootstrap_next(uint8_t *count)
-{
- // Let the increment gradually grow in a sensible way.
- time_t increment = 5 * (*count) * (*count);
-
- if (increment < 7200) { // two hours
- (*count)++;
- } else {
- increment = 7200;
- }
-
- // Add a random delay to prevent burst refresh.
- return increment + dnssec_random_uint16_t() % 30;
-}
-
static void limit_timer(conf_t *conf, const knot_dname_t *zone, uint32_t *timer,
const char *tm_name, const yp_name_t *low, const yp_name_t *upp)
{
if (soa) {
next = knot_soa_retry(soa->rdata);
} else {
- next = bootstrap_next(&zone->zonefile.bootstrap_cnt);
+ next = zone_bootstrap_next(&zone->zonefile.bootstrap_cnt);
}
limit_timer(conf, zone->name, &next, "retry",
return ret;
}
+
+time_t zone_bootstrap_next(uint8_t *count)
+{
+ // Let the increment gradually grow in a sensible way.
+ time_t increment = 5 * (*count) * (*count);
+
+ if (increment < 7200) { // two hours
+ (*count)++;
+ } else {
+ increment = 7200;
+ }
+
+ // Add a random delay to prevent burst refresh.
+ return increment + dnssec_random_uint16_t() % 30;
+}
int zone_get_lastsigned_serial(zone_t *zone, uint32_t *serial);
int slave_zone_serial(zone_t *zone, conf_t *conf, uint32_t *serial);
+
+time_t zone_bootstrap_next(uint8_t *count);