]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
zone/timers: refactoring: allocated separately from zone_t
authorLibor Peltan <libor.peltan@nic.cz>
Tue, 4 Nov 2025 12:58:45 +0000 (13:58 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Fri, 21 Nov 2025 13:35:41 +0000 (14:35 +0100)
15 files changed:
src/knot/catalog/generate.c
src/knot/dnssec/zone-sign.c
src/knot/events/handlers/dnssec.c
src/knot/events/handlers/ds_check.c
src/knot/events/handlers/ds_push.c
src/knot/events/handlers/load.c
src/knot/events/handlers/notify.c
src/knot/events/handlers/refresh.c
src/knot/events/replan.c
src/knot/nameserver/process_query.c
src/knot/zone/backup.c
src/knot/zone/timers.c
src/knot/zone/zone.c
src/knot/zone/zone.h
src/knot/zone/zonedb-load.c

index f12da65f5e57a7c3fb8611e1bc85a201bf9cb847..852fe5e6235810026812cf661851e3d047f063f3 100644 (file)
@@ -66,7 +66,7 @@ void catalog_generate_rem(conf_t *conf, zone_t *zone, knot_zonedb_t *db_new)
                return;
        }
        assert(catz->cat_members != NULL); // if this failed to allocate, catz wasn't added to zonedb
-       knot_dname_t *owner = catalog_member_owner(zone->name, cg, zone->timers.catalog_member);
+       knot_dname_t *owner = catalog_member_owner(zone->name, cg, zone->timers->catalog_member);
        if (owner == NULL) {
                catz->cat_members->error = KNOT_ENOENT;
                return;
@@ -98,7 +98,7 @@ void catalog_generate_add(conf_t *conf, zone_t *zone, knot_zonedb_t *db_new, boo
                log_zone_error(zone->name, "member zone belongs to non-generated catalog zone");
                return;
        }
-       knot_dname_t *owner = catalog_member_owner(zone->name, cg, zone->timers.catalog_member);
+       knot_dname_t *owner = catalog_member_owner(zone->name, cg, zone->timers->catalog_member);
        if (owner == NULL) {
                catz->cat_members->error = KNOT_ENOENT;
                return;
index c090ab1129455c7a537864f5c591730ff2f2a3b3..856c089cf64ed8ba68179c612597ad3cd7d40246 100644 (file)
@@ -886,8 +886,8 @@ int knot_zone_sign_update_dnskeys(zone_update_t *update,
 
        if (dnssec_ctx->policy->ds_push && node_rrtype_exists(ch.add->apex, KNOT_RRTYPE_CDS)) {
                // there is indeed a change to CDS
-               update->zone->timers.next_ds_push = time(NULL) + dnssec_ctx->policy->propagation_delay;
-               zone_events_schedule_at(update->zone, ZONE_EVENT_DS_PUSH, update->zone->timers.next_ds_push);
+               update->zone->timers->next_ds_push = time(NULL) + dnssec_ctx->policy->propagation_delay;
+               zone_events_schedule_at(update->zone, ZONE_EVENT_DS_PUSH, update->zone->timers->next_ds_push);
        }
 
        ret = zone_update_apply_changeset(update, &ch);
index e451ce20a5feadac451942228bd3ae3ff14bfe71..0150bdd3b66c95de8fd6329049257f85f9a7a48d 100644 (file)
@@ -40,7 +40,7 @@ void event_dnssec_reschedule(conf_t *conf, zone_t *zone,
        log_dnssec_next(zone->name, (time_t)refresh_at);
 
        if (refresh->plan_ds_check) {
-               zone->timers.next_ds_check = now;
+               zone->timers->next_ds_check = now;
        }
 
        unsigned jitter = dnskey_sync_jitter(conf, zone);
index 2a9a5a50f038d41be403b6c3414fd8297927e6d9..f4f8cae2b378d60badc750bd7b4b39c287b41a2b 100644 (file)
@@ -24,7 +24,7 @@ int event_ds_check(conf_t *conf, zone_t *zone)
        ret = knot_parent_ds_query(conf, &ctx, zone->server,
                                   conf->cache.srv_tcp_remote_io_timeout);
 
-       zone->timers.next_ds_check = 0;
+       zone->timers->next_ds_check = 0;
        switch (ret) {
        case KNOT_NO_READY_KEY:
                break;
@@ -34,7 +34,7 @@ int event_ds_check(conf_t *conf, zone_t *zone)
        default:
                if (ctx.policy->ksk_sbm_check_interval > 0) {
                        time_t next_check = time(NULL) + ctx.policy->ksk_sbm_check_interval;
-                       zone->timers.next_ds_check = next_check;
+                       zone->timers->next_ds_check = next_check;
                        zone_events_schedule_at(zone, ZONE_EVENT_DS_CHECK, next_check);
                }
        }
index 1c53b993fb5d36574c0252a11686f0196d9549ad..deb6392050a59738bf86845d3299aac35f8a1a66 100644 (file)
@@ -239,7 +239,7 @@ int event_ds_push(conf_t *conf, zone_t *zone)
                        conf_remote_t parent = conf_remote(conf, iter.id, i);
                        ret = send_ds_push(conf, zone, &parent, timeout);
                        if (ret == KNOT_EOK) {
-                               zone->timers.next_ds_push = 0;
+                               zone->timers->next_ds_push = 0;
                                break;
                        }
                }
@@ -247,7 +247,7 @@ int event_ds_push(conf_t *conf, zone_t *zone)
                if (ret != KNOT_EOK) {
                        time_t next_push = time(NULL) + DS_PUSH_RETRY;
                        zone_events_schedule_at(zone, ZONE_EVENT_DS_PUSH, next_push);
-                       zone->timers.next_ds_push = next_push;
+                       zone->timers->next_ds_push = next_push;
                }
 
                conf_mix_iter_next(&iter);
index 0ca539f720b78e656aa49f41d48e13adbd0fab3d..b19c443bd1b63f6d742846348e12f31e61191444 100644 (file)
@@ -485,10 +485,10 @@ load_end:
        }
 
        char expires_in[32] = "";
-       if (zone->timers.next_expire > 0) {
+       if (zone->timers->next_expire > 0) {
                (void)snprintf(expires_in, sizeof(expires_in),
                               ", expires in %u seconds",
-                              (uint32_t)MAX(zone->timers.next_expire - time(NULL), 0));
+                              (uint32_t)MAX(zone->timers->next_expire - time(NULL), 0));
        }
 
        log_zone_info(zone->name, "loaded, serial %s -> %u%s, %zu bytes%s",
@@ -505,7 +505,7 @@ load_end:
 
        replan_from_timers(conf, zone);
 
-       if (!zone_timers_serial_notified(&zone->timers, new_serial)) {
+       if (!zone_timers_serial_notified(zone->timers, new_serial)) {
                zone_schedule_notify(conf, zone, 0);
        }
        zone_redis_disconnect(db_ctx, true);
index 1b9a7a7fe2a320c24bb3e397f297c2570705522d..b8a54232ce4452481dd67aead061daae01745ba6 100644 (file)
@@ -111,7 +111,7 @@ static int send_notify(conf_t *conf, zone_t *zone, const knot_rrset_t *soa,
                NOTIFY_OUT_LOG(LOG_INFO, zone->name, slave,
                               requestor.layer.flags,
                               "%sserial %u", log_retry, knot_soa_serial(soa->rrs.rdata));
-               zone->timers.last_notified_serial = (knot_soa_serial(soa->rrs.rdata) | LAST_NOTIFIED_SERIAL_VALID);
+               zone->timers->last_notified_serial = (knot_soa_serial(soa->rrs.rdata) | LAST_NOTIFIED_SERIAL_VALID);
        } else if (knot_pkt_ext_rcode(req->resp) == 0) {
                NOTIFY_OUT_LOG(LOG_WARNING, zone->name, slave,
                               requestor.layer.flags,
index 544fbe9c9fd57df80f5dbc157f88333fd0611091..5c0b34bfb32b371051501a2c39de9107aea09b73 100644 (file)
@@ -199,7 +199,7 @@ static void consume_edns_expire(struct refresh_data *data, knot_pkt_t *pkt, bool
        if (expire_opt != NULL && knot_edns_opt_get_length(expire_opt) == sizeof(uint32_t)) {
                uint32_t edns_expire = knot_wire_read_u32(knot_edns_opt_get_data(expire_opt));
                data->expire_timer = strictly_follow ? edns_expire :
-                                    MAX(edns_expire, data->zone->timers.next_expire - time(NULL));
+                                    MAX(edns_expire, data->zone->timers->next_expire - time(NULL));
        }
 }
 
@@ -218,19 +218,19 @@ static void finalize_timers_base(struct refresh_data *data, bool also_expire)
        uint32_t soa_refresh = knot_soa_refresh(soa->rdata);
        limit_timer(conf, zone->name, &soa_refresh, "refresh",
                    C_REFRESH_MIN_INTERVAL, C_REFRESH_MAX_INTERVAL);
-       zone->timers.next_refresh = now + soa_refresh;
-       zone->timers.last_refresh_ok = true;
+       zone->timers->next_refresh = now + soa_refresh;
+       zone->timers->last_refresh_ok = true;
 
        if (zone->is_catalog_flag) {
                // It's already zero in most cases.
-               zone->timers.next_expire = 0;
+               zone->timers->next_expire = 0;
        } else if (also_expire) {
                limit_timer(conf, zone->name, &data->expire_timer, "expire",
                            // Limit min if not received as EDNS Expire.
                            data->expire_timer == knot_soa_expire(soa->rdata) ?
                              C_EXPIRE_MIN_INTERVAL : 0,
                            C_EXPIRE_MAX_INTERVAL);
-               zone->timers.next_expire = now + data->expire_timer;
+               zone->timers->next_expire = now + data->expire_timer;
        }
 }
 
@@ -246,8 +246,8 @@ static void finalize_timers_noexpire(struct refresh_data *data)
 
 static void fill_expires_in(char *expires_in, size_t size, const struct refresh_data *data)
 {
-       assert(!data->zone->is_catalog_flag || data->zone->timers.next_expire == 0);
-       if (data->zone->timers.next_expire > 0 && data->expire_timer > 0) {
+       assert(!data->zone->is_catalog_flag || data->zone->timers->next_expire == 0);
+       if (data->zone->timers->next_expire > 0 && data->expire_timer > 0) {
                (void)snprintf(expires_in, size,
                               ", expires in %u seconds", data->expire_timer);
        }
@@ -1074,24 +1074,24 @@ static bool wait4pinned_master(struct refresh_data *data)
        } else if (data->fallback->trying_last) {
                return false;
        // Pinned master expected but not yet set, force AXFR (e.g. dropped timers).
-       } else if (data->zone->timers.last_master.sin6_family == AF_UNSPEC) {
+       } else if (data->zone->timers->last_master.sin6_family == AF_UNSPEC) {
                data->xfr_type = XFR_TYPE_AXFR;
                return false;
        }
 
        time_t now = time(NULL);
        // Starting countdown for master transition.
-       if (data->zone->timers.master_pin_hit == 0) {
-               data->zone->timers.master_pin_hit = now;
+       if (data->zone->timers->master_pin_hit == 0) {
+               data->zone->timers->master_pin_hit = now;
                zone_events_schedule_at(data->zone, ZONE_EVENT_REFRESH, now + data->fallback->pin_tol);
        // Switch to a new master.
-       } else if (data->zone->timers.master_pin_hit + data->fallback->pin_tol <= now) {
+       } else if (data->zone->timers->master_pin_hit + data->fallback->pin_tol <= now) {
                data->xfr_type = XFR_TYPE_AXFR;
                return false;
        // Replan the refresh to the moment when the pin tolerance times out.
        } else {
                zone_events_schedule_at(data->zone, ZONE_EVENT_REFRESH,
-                                       data->zone->timers.master_pin_hit + data->fallback->pin_tol);
+                                       data->zone->timers->master_pin_hit + data->fallback->pin_tol);
        }
 
        return true;
@@ -1505,19 +1505,19 @@ int event_refresh(conf_t *conf, zone_t *zone)
                limit_timer(conf, zone->name, &next, "retry",
                            C_RETRY_MIN_INTERVAL, C_RETRY_MAX_INTERVAL);
                time_t now = time(NULL);
-               zone->timers.next_refresh = now + next;
-               zone->timers.last_refresh_ok = false;
+               zone->timers->next_refresh = now + next;
+               zone->timers->last_refresh_ok = false;
 
                char time_str[64] = { 0 };
                struct tm time_gm = { 0 };
-               localtime_r(&zone->timers.next_refresh, &time_gm);
+               localtime_r(&zone->timers->next_refresh, &time_gm);
                strftime(time_str, sizeof(time_str), KNOT_LOG_TIME_FORMAT, &time_gm);
 
                char expires_in[32] = "";
                if (!zone->is_catalog_flag) {
                        struct refresh_data data = {
                                .zone = zone,
-                               .expire_timer = zone->timers.next_expire - now,
+                               .expire_timer = zone->timers->next_expire - now,
                        };
                        fill_expires_in(expires_in, sizeof(expires_in), &data);
                }
index e219d438333b034c2c3cc9838a853e82cd6909bc..203ad4db12838ffa7adc7455c5d4afb68e149d24 100644 (file)
@@ -94,8 +94,8 @@ void replan_from_timers(conf_t *conf, zone_t *zone)
 
        time_t refresh = TIME_CANCEL;
        if (zone_is_slave(conf, zone)) {
-               refresh = zone->timers.next_refresh;
-               if (zone->contents == NULL && zone->timers.last_refresh_ok) { // zone disappeared w/o expiry
+               refresh = zone->timers->next_refresh;
+               if (zone->contents == NULL && zone->timers->last_refresh_ok) { // zone disappeared w/o expiry
                        refresh = now;
                }
                if (refresh == 0) { // sanitize in case of concurrent purge event
@@ -108,7 +108,7 @@ void replan_from_timers(conf_t *conf, zone_t *zone)
        time_t expire = TIME_IGNORE;
        if (zone_is_slave(conf, zone) && zone->contents != NULL) {
                expire_pre = TIME_CANCEL;
-               expire = zone->timers.next_expire;
+               expire = zone->timers->next_expire;
        }
 
        time_t flush = TIME_IGNORE;
@@ -116,7 +116,7 @@ void replan_from_timers(conf_t *conf, zone_t *zone)
                conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
                int64_t sync_timeout = conf_int(&val);
                if (sync_timeout > 0) {
-                       flush = zone->timers.last_flush + sync_timeout;
+                       flush = zone->timers->last_flush + sync_timeout;
                }
        }
 
@@ -143,11 +143,11 @@ void replan_from_timers(conf_t *conf, zone_t *zone)
                        }
                }
 
-               ds_check = zone->timers.next_ds_check;
+               ds_check = zone->timers->next_ds_check;
                if (ds_check == 0) {
                        ds_check = TIME_IGNORE;
                }
-               ds_push = zone->timers.next_ds_push;
+               ds_push = zone->timers->next_ds_push;
                if (ds_push == 0) {
                        ds_push = TIME_IGNORE;
                }
index b0442608119ff53f7cd6531b6617a14685337d9c..f9d79f588a4bb6d47f5b465bab9c81c7067607d3 100644 (file)
@@ -353,7 +353,7 @@ static int answer_edns_put(knot_pkt_t *resp, knotd_qdata_t *qdata)
        if (knot_pkt_edns_option(qdata->query, KNOT_EDNS_OPTION_EXPIRE) != NULL &&
            qdata->extra->contents != NULL && !qdata->extra->zone->is_catalog_flag) {
                knot_time_t expire = knot_time_min(ATOMIC_GET(qdata->extra->contents->dnssec_expire),
-                                                  qdata->extra->zone->timers.next_expire);
+                                                  qdata->extra->zone->timers->next_expire);
                uint32_t timer;
                if (expire == 0) {
                        timer = zone_soa_expire(qdata->extra->zone);
index 49f460b3ed210af20515fc380eea7f489a02a144..8ffe1441cba7dd3c79dabef5cb6592cb5daea09d 100644 (file)
@@ -494,11 +494,11 @@ int zone_backup(conf_t *conf, zone_t *zone)
                        return ret;
                }
                if (ctx->restore_mode) {
-                       ret = zone_timers_read(&ctx->bck_timer_db, zone->name, &zone->timers);
+                       ret = zone_timers_read(&ctx->bck_timer_db, zone->name, zone->timers);
                        zone_timers_sanitize(conf, zone);
                        zone->zonefile.bootstrap_cnt = 0;
                } else {
-                       ret = zone_timers_write(&ctx->bck_timer_db, zone->name, &zone->timers);
+                       ret = zone_timers_write(&ctx->bck_timer_db, zone->name, zone->timers);
                }
                if (ret != KNOT_EOK) {
                        LOG_MARK_FAIL("timers");
index 40e3414901743a4980526d249af3e828bae6b13d..9c8877951788d3e754291aca73d260aad403465c 100644 (file)
@@ -199,7 +199,7 @@ int zone_timers_write(knot_lmdb_db_t *db, const knot_dname_t *zone,
 
 static void txn_zone_write(zone_t *z, knot_lmdb_txn_t *txn)
 {
-       txn_write_timers(txn, z->name, &z->timers);
+       txn_write_timers(txn, z->name, z->timers);
 }
 
 int zone_timers_write_all(knot_lmdb_db_t *db, knot_zonedb_t *zonedb)
index 8d28ec4b7fde428ecda019a42414c8ecac87b232..f5c6a25de1c5f9f5005da01187acfd41ccf50ba2 100644 (file)
@@ -140,9 +140,9 @@ static int flush_journal(conf_t *conf, zone_t *zone, bool allow_empty_zone, bool
 
 flush_journal_replan:
        /* Plan next journal flush after proper period. */
-       zone->timers.last_flush = time(NULL);
+       zone->timers->last_flush = time(NULL);
        if (sync_timeout > 0) {
-               time_t next_flush = zone->timers.last_flush + sync_timeout;
+               time_t next_flush = zone->timers->last_flush + sync_timeout;
                zone_events_schedule_at(zone, ZONE_EVENT_FLUSH, (time_t)0,
                                              ZONE_EVENT_FLUSH, next_flush);
        }
@@ -164,6 +164,13 @@ zone_t* zone_new(const knot_dname_t *name)
                return NULL;
        }
 
+       zone->timers = calloc(1, sizeof(*zone->timers));
+       if (zone->timers == NULL) {
+               knot_dname_free(zone->name, NULL);
+               free(zone);
+               return NULL;
+       }
+
        // DDNS
        pthread_mutex_init(&zone->ddns_lock, NULL);
        zone->ddns_queue_size = 0;
@@ -247,6 +254,7 @@ void zone_free(zone_t **zone_ptr)
 
        ATOMIC_DEINIT(zone->backup_ctx);
 
+       free(zone->timers);
        free(zone);
        *zone_ptr = NULL;
 }
@@ -297,13 +305,13 @@ int selective_zone_purge(conf_t *conf, zone_t *zone, purge_flag_t params)
 
        // Purge the zone timers.
        if (params & PURGE_ZONE_TIMERS) {
-               bool member = (zone->catalog_gen != NULL);
-               zone->timers = (zone_timers_t) {
-                       .catalog_member = member ? zone->timers.catalog_member : 0
-               };
+               time_t member = (zone->catalog_gen != NULL ? zone->timers->catalog_member : 0);
+               memset(zone->timers, 0, sizeof(*zone->timers));
+               zone->timers->catalog_member = member;
+
                if (member) {
                        ret = zone_timers_write(&zone->server->timerdb, zone->name,
-                                               &zone->timers);
+                                               zone->timers);
                } else {
                        ret = zone_timers_sweep(&zone->server->timerdb,
                                                dname_cmp_sweep_wrap, zone->name);
@@ -379,8 +387,8 @@ void zone_perform_expire(conf_t *conf, zone_t *zone)
 
        zone_set_last_master(zone, NULL);
 
-       zone->timers.next_expire = time(NULL);
-       zone->timers.next_refresh = zone->timers.next_expire;
+       zone->timers->next_expire = time(NULL);
+       zone->timers->next_refresh = zone->timers->next_expire;
        replan_from_timers(conf, zone);
 }
 
@@ -585,11 +593,11 @@ void zone_set_last_master(zone_t *zone, const struct sockaddr_storage *addr)
        }
 
        if (addr == NULL) {
-               memset(&zone->timers.last_master, 0, sizeof(zone->timers.last_master));
+               memset(&zone->timers->last_master, 0, sizeof(zone->timers->last_master));
        } else {
-               memcpy(&zone->timers.last_master, addr, sizeof(zone->timers.last_master));
+               memcpy(&zone->timers->last_master, addr, sizeof(zone->timers->last_master));
        }
-       zone->timers.master_pin_hit = 0;
+       zone->timers->master_pin_hit = 0;
 }
 
 static void set_flag(zone_t *zone, zone_flag_t flag, bool remove)
@@ -655,9 +663,7 @@ bool zone_expired(const zone_t *zone)
                return false;
        }
 
-       const zone_timers_t *timers = &zone->timers;
-
-       return timers->next_expire > 0 && timers->next_expire <= time(NULL);
+       return zone->timers->next_expire > 0 && zone->timers->next_expire <= time(NULL);
 }
 
 static void time_set_default(time_t *time, time_t value)
@@ -677,20 +683,20 @@ void zone_timers_sanitize(conf_t *conf, zone_t *zone)
        time_t now = time(NULL);
 
        // assume now if we don't know when we flushed
-       time_set_default(&zone->timers.last_flush, now);
+       time_set_default(&zone->timers->last_flush, now);
 
        if (zone_is_slave(conf, zone)) {
                // assume now if we don't know
-               time_set_default(&zone->timers.next_refresh, now);
+               time_set_default(&zone->timers->next_refresh, now);
                if (zone->is_catalog_flag) {
-                       zone->timers.next_expire = 0;
+                       zone->timers->next_expire = 0;
                }
        } else {
                // invalidate if we don't have a master
-               zone->timers.last_refresh = 0;
-               zone->timers.next_refresh = 0;
-               zone->timers.last_refresh_ok = false;
-               zone->timers.next_expire = 0;
+               zone->timers->last_refresh = 0;
+               zone->timers->next_refresh = 0;
+               zone->timers->last_refresh_ok = false;
+               zone->timers->next_expire = 0;
        }
 }
 
@@ -760,7 +766,7 @@ int zone_master_try(conf_t *conf, zone_t *zone, zone_master_cb callback,
                                preferred_2x = (zone->flags & ZONE_PREF_MASTER_2X);
                        }
                        if (pin_tolerance > 0 &&
-                           sockaddr_net_match(&remote.addr, (struct sockaddr_storage *)&zone->timers.last_master, -1)) {
+                           sockaddr_net_match(&remote.addr, (struct sockaddr_storage *)&zone->timers->last_master, -1)) {
                                last_id = conf_str(iter.id);
                                last = *iter.id;
                                last_idx = idx;
@@ -919,20 +925,20 @@ int zone_get_master_serial(zone_t *zone, uint32_t *serial)
 
 void zone_set_lastsigned_serial(zone_t *zone, uint32_t serial)
 {
-       zone->timers.last_signed_serial = serial;
-       zone->timers.last_signed_s_flags = LAST_SIGNED_SERIAL_FOUND | LAST_SIGNED_SERIAL_VALID;
+       zone->timers->last_signed_serial = serial;
+       zone->timers->last_signed_s_flags = LAST_SIGNED_SERIAL_FOUND | LAST_SIGNED_SERIAL_VALID;
 }
 
 int zone_get_lastsigned_serial(zone_t *zone, uint32_t *serial)
 {
-       if (!(zone->timers.last_signed_s_flags & LAST_SIGNED_SERIAL_FOUND)) {
+       if (!(zone->timers->last_signed_s_flags & LAST_SIGNED_SERIAL_FOUND)) {
                // backwards compatibility: it used to be stored in KASP DB, moved to timers for performance
                return kasp_db_load_serial(zone_kaspdb(zone), zone->name, KASPDB_SERIAL_LASTSIGNED, serial);
        }
-       if (!(zone->timers.last_signed_s_flags & LAST_SIGNED_SERIAL_VALID)) {
+       if (!(zone->timers->last_signed_s_flags & LAST_SIGNED_SERIAL_VALID)) {
                return KNOT_ENOENT;
        }
-       *serial = zone->timers.last_signed_serial;
+       *serial = zone->timers->last_signed_serial;
        return KNOT_EOK;
 }
 
index 52088de85e4789347a1327e8ffce1216220346dd..28788e2fc2f502e4062d7fa3a9ff1d82a9a3a647 100644 (file)
@@ -100,7 +100,7 @@ typedef struct zone
        } zonefile;
 
        /*! \brief Zone events. */
-       zone_timers_t timers;      //!< Persistent zone timers.
+       zone_timers_t *timers;      //!< Persistent zone timers.
        zone_events_t events;      //!< Zone events timers.
 
        /*! \brief Track unsuccessful NOTIFY targets. */
index f7135b0df3f34caa95abdc018331f8d37394d5db..933a2cb2078f5c841212d688c4487d0d8890c061 100644 (file)
@@ -103,7 +103,7 @@ static zone_t *create_zone_reload(conf_t *conf, const knot_dname_t *name,
        zone->contents = old_zone->contents;
        zone_set_flag(zone, zone_get_flag(old_zone, ~0, false));
 
-       zone->timers = old_zone->timers;
+       memcpy(zone->timers, old_zone->timers, sizeof(*zone->timers));
        zone_timers_sanitize(conf, zone);
 
        if (old_zone->control_update != NULL) {
@@ -128,7 +128,7 @@ static zone_t *create_zone_new(conf_t *conf, const knot_dname_t *name,
                return NULL;
        }
 
-       int ret = zone_timers_read(&server->timerdb, name, &zone->timers);
+       int ret = zone_timers_read(&server->timerdb, name, zone->timers);
        if (ret != KNOT_EOK && ret != KNOT_ENODB && ret != KNOT_ENOENT) {
                log_zone_error(zone->name, "failed to load persistent timers (%s)",
                               knot_strerror(ret));
@@ -144,10 +144,10 @@ static zone_t *create_zone_new(conf_t *conf, const knot_dname_t *name,
                conf_val_t catz = conf_zone_get(conf, C_CATALOG_ZONE, name);
                assert(catz.code == KNOT_EOK); // conf consistency checked in conf/tools.c
                zone->catalog_gen = knot_dname_copy(conf_dname(&catz), NULL);
-               if (zone->timers.catalog_member == 0) {
-                       zone->timers.catalog_member = time(NULL);
+               if (zone->timers->catalog_member == 0) {
+                       zone->timers->catalog_member = time(NULL);
                        ret = zone_timers_write(&zone->server->timerdb, zone->name,
-                                               &zone->timers);
+                                               zone->timers);
                }
                if (ret != KNOT_EOK || zone->catalog_gen == NULL) {
                        log_zone_error(zone->name, "failed to initialize catalog member zone (%s)",
@@ -226,8 +226,8 @@ static void zone_purge(conf_t *conf, zone_t *zone)
 static zone_contents_t *zone_expire(zone_t *zone, bool zonedb_cow)
 {
        if (!zonedb_cow) {
-               zone->timers.next_expire = time(NULL);
-               zone->timers.next_refresh = zone->timers.next_expire;
+               zone->timers->next_expire = time(NULL);
+               zone->timers->next_refresh = zone->timers->next_expire;
        }
        return zone_switch_contents(zone, NULL);
 }