Commit c62571a9 authored by Jan Včelák's avatar Jan Včelák 🚀

adapt to cleaned-up scheduler API

parent 32aa7744
......@@ -244,7 +244,7 @@ static int zone_reload(zone_t *zone, ctl_args_t *args)
return KNOT_ENOTSUP;
}
zone_events_schedule(zone, ZONE_EVENT_LOAD, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_LOAD);
return KNOT_EOK;
}
......@@ -257,7 +257,7 @@ static int zone_refresh(zone_t *zone, ctl_args_t *args)
return KNOT_ENOTSUP;
}
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_REFRESH);
return KNOT_EOK;
}
......@@ -271,7 +271,7 @@ static int zone_retransfer(zone_t *zone, ctl_args_t *args)
}
zone->flags |= ZONE_FORCE_AXFR;
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_REFRESH);
return KNOT_EOK;
}
......@@ -284,7 +284,7 @@ static int zone_flush(zone_t *zone, ctl_args_t *args)
zone->flags |= ZONE_FORCE_FLUSH;
}
zone_events_schedule(zone, ZONE_EVENT_FLUSH, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_FLUSH);
return KNOT_EOK;
}
......@@ -299,7 +299,7 @@ static int zone_sign(zone_t *zone, ctl_args_t *args)
}
zone->flags |= ZONE_FORCE_RESIGN;
zone_events_schedule(zone, ZONE_EVENT_DNSSEC, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_DNSSEC);
return KNOT_EOK;
}
......@@ -348,10 +348,10 @@ static int zone_txn_commit(zone_t *zone, ctl_args_t *args)
/* Sync zonefile immediately if configured. */
conf_val_t val = conf_zone_get(conf(), C_ZONEFILE_SYNC, zone->name);
if (conf_int(&val) == 0) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_FLUSH);
}
zone_events_schedule(zone, ZONE_EVENT_NOTIFY, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_NOTIFY);
return KNOT_EOK;
}
......
......@@ -20,6 +20,7 @@
#include "knot/common/log.h"
#include "knot/conf/conf.h"
#include "knot/events/handlers.h"
#include "knot/events/log.h"
#include "knot/zone/zone-load.h"
#include "knot/zone/zone.h"
#include "knot/zone/zonefile.h"
......@@ -86,24 +87,25 @@ int event_load(conf_t *conf, zone_t *zone)
/* Schedule notify and refresh after load. */
if (zone_is_slave(conf, zone)) {
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_REFRESH);
}
if (!zone_contents_is_empty(contents)) {
zone_events_schedule(zone, ZONE_EVENT_NOTIFY, ZONE_EVENT_NOW);
zone->bootstrap_retry = ZONE_EVENT_NOW;
zone_events_schedule_now(zone, ZONE_EVENT_NOTIFY);
zone->bootstrap_retry = 0;
}
/* Schedule zone resign. */
conf_val_t val = conf_zone_get(conf, C_DNSSEC_SIGNING, zone->name);
if (conf_bool(&val)) {
schedule_dnssec(zone, dnssec_refresh);
log_dnssec_next(zone->name, dnssec_refresh);
zone_events_schedule_at(zone, ZONE_EVENT_DNSSEC, dnssec_refresh);
}
/* Periodic execution. */
val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
int64_t sync_timeout = conf_int(&val);
if (sync_timeout >= 0) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, sync_timeout);
//zone_events_schedule(zone, ZONE_EVENT_FLUSH, sync_timeout);
}
uint32_t current_serial = zone_contents_serial(zone->contents);
......@@ -130,9 +132,9 @@ fail:
zone_contents_deep_free(&contents);
/* Try to bootstrap the zone if local error. */
if (zone_is_slave(conf, zone) && !zone_events_is_scheduled(zone, ZONE_EVENT_REFRESH)) {
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
}
//if (zone_is_slave(conf, zone) && !zone_events_is_scheduled(zone, ZONE_EVENT_REFRESH)) {
// zone_events_schedule_now(zone, ZONE_EVENT_REFRESH);
//}
return ret;
}
......@@ -783,11 +783,11 @@ uint32_t bootstrap_next(uint32_t interval)
/*! \brief Schedule expire event, unless it is already scheduled. */
static void start_expire_timer(conf_t *conf, zone_t *zone, const knot_rdataset_t *soa)
{
if (zone_events_is_scheduled(zone, ZONE_EVENT_EXPIRE)) {
return;
}
//if (zone_events_is_scheduled(zone, ZONE_EVENT_EXPIRE)) {
// return;
//}
zone_events_schedule(zone, ZONE_EVENT_EXPIRE, knot_soa_expire(soa));
zone_events_schedule_at(zone, ZONE_EVENT_EXPIRE, time(NULL) + knot_soa_expire(soa));
}
int event_refresh(conf_t *conf, zone_t *zone)
......@@ -824,7 +824,7 @@ int event_refresh(conf_t *conf, zone_t *zone)
}
zone->timers.next_refresh = time(NULL) + next;
zone_events_schedule(zone, ZONE_EVENT_REFRESH, next);
zone_events_schedule_at(zone, ZONE_EVENT_REFRESH, time(NULL) + next);
// TODO: temporary until timers are refactored
if (ret != KNOT_EOK) {
......
......@@ -41,7 +41,7 @@ int event_update(conf_t *conf, zone_t *zone)
pthread_mutex_unlock(&zone->ddns_lock);
if (!empty) {
zone_events_schedule(zone, ZONE_EVENT_UPDATE, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_UPDATE);
}
return KNOT_EOK;
......
......@@ -27,7 +27,7 @@
static void replan_event(zone_t *zone, const zone_t *old_zone, zone_event_type_t e)
{
const time_t event_time = zone_events_get_time(old_zone, e);
if (event_time > ZONE_EVENT_NOW) {
if (event_time > 1) {
zone_events_schedule_at(zone, e, event_time);
}
}
......@@ -50,7 +50,7 @@ static void replan_soa_events(conf_t *conf, zone_t *zone, const zone_t *old_zone
const knot_rdataset_t *soa = node_rdataset(zone->contents->apex,
KNOT_RRTYPE_SOA);
assert(soa);
zone_events_schedule(zone, ZONE_EVENT_REFRESH, knot_soa_refresh(soa));
zone_events_schedule_at(zone, ZONE_EVENT_REFRESH, time(NULL) + knot_soa_refresh(soa));
}
}
}
......@@ -66,9 +66,9 @@ static void replan_flush(conf_t *conf, zone_t *zone, const zone_t *old_zone)
}
const time_t flush_time = zone_events_get_time(old_zone, ZONE_EVENT_FLUSH);
if (flush_time <= ZONE_EVENT_NOW) {
if (flush_time <= 1) {
// Not scheduled previously.
zone_events_schedule(zone, ZONE_EVENT_FLUSH, sync_timeout);
zone_events_schedule_at(zone, ZONE_EVENT_FLUSH, time(NULL) + sync_timeout);
return;
}
......@@ -96,7 +96,7 @@ static void replan_dnssec(conf_t *conf, zone_t *zone)
conf_val_t val = conf_zone_get(conf, C_DNSSEC_SIGNING, zone->name);
if (conf_bool(&val)) {
/* Keys could have changed, force resign. */
zone_events_schedule(zone, ZONE_EVENT_DNSSEC, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_DNSSEC);
}
}
......@@ -109,7 +109,7 @@ void replan_update(zone_t *zone, zone_t *old_zone)
}
if (have_updates) {
zone_events_schedule(zone, ZONE_EVENT_UPDATE, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_UPDATE);
}
}
......
......@@ -81,7 +81,7 @@ int notify_process_query(knot_pkt_t *pkt, struct query_data *qdata)
/* Incoming NOTIFY expires REFRESH timer and renews EXPIRE timer. */
zone_t *zone = (zone_t *)qdata->zone;
zone_set_preferred_master(zone, qdata->param->remote);
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_REFRESH);
return KNOT_STATE_DONE;
}
......@@ -165,7 +165,7 @@ static int process_normal(conf_t *conf, zone_t *zone, list_t *requests)
/* Sync zonefile immediately if configured. */
conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
if (conf_int(&val) == 0) {
zone_events_schedule(zone, ZONE_EVENT_FLUSH, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_FLUSH);
}
return KNOT_EOK;
......@@ -200,7 +200,7 @@ static void process_requests(conf_t *conf, zone_t *zone, list_t *requests)
"%.02f seconds", old_serial, new_serial,
time_diff_ms(&t_start, &t_end));
zone_events_schedule(zone, ZONE_EVENT_NOTIFY, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_NOTIFY);
}
static int remote_forward(conf_t *conf, struct knot_request *request, conf_remote_t *remote)
......
......@@ -445,7 +445,7 @@ int zone_update_enqueue(zone_t *zone, knot_pkt_t *pkt, struct process_query_para
pthread_mutex_unlock(&zone->ddns_lock);
/* Schedule UPDATE event. */
zone_events_schedule(zone, ZONE_EVENT_UPDATE, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_UPDATE);
return KNOT_EOK;
}
......
......@@ -232,7 +232,7 @@ static zone_t *create_zone_new(conf_t *conf, const knot_dname_t *name,
case ZONE_STATUS_BOOSTRAP:
if (zone_events_get_time(zone, ZONE_EVENT_REFRESH) == 0) {
// Plan immediate refresh if not already planned.
zone_events_schedule(zone, ZONE_EVENT_REFRESH, ZONE_EVENT_NOW);
zone_events_schedule_now(zone, ZONE_EVENT_REFRESH);
}
break;
case ZONE_STATUS_NOT_FOUND:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment