Skip to content
Snippets Groups Projects
Commit ab1dd760 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

DNSSEC: schedule all depending events at once

parent 2ec61209
Branches
Tags
No related merge requests found
......@@ -33,7 +33,6 @@ int event_flush(conf_t *conf, zone_t *zone);
int event_notify(conf_t *conf, zone_t *zone);
/*! \brief Signs the zone using its DNSSEC keys. */
int event_dnssec(conf_t *conf, zone_t *zone);
void schedule_dnssec(zone_t *zone, time_t refresh_at);
/*! \brief Get next bootstrap interval. */
uint32_t bootstrap_next(uint32_t interval);
......@@ -20,34 +20,24 @@
#include "knot/common/log.h"
#include "knot/conf/conf.h"
#include "knot/dnssec/zone-events.h"
#include "knot/events/log.h"
#include "knot/updates/apply.h"
#include "knot/zone/zone.h"
#include "libknot/errcode.h"
/*!
* \todo Separate signing from zone loading and drop this function.
*
* DNSSEC signing is planned from two places - after zone loading and after
* successful resign. This function just logs the message and reschedules the
* DNSSEC timer.
*
* I would rather see the invocation of the signing from event_dnssec()
* function. This would require to split refresh event to zone load and zone
* publishing.
*/
void schedule_dnssec(zone_t *zone, time_t refresh_at)
static void reschedule(conf_t *conf, zone_t *zone,
time_t dnssec_refresh, bool zone_changed)
{
// log a message
char time_str[64] = { 0 };
struct tm time_gm = { 0 };
localtime_r(&refresh_at, &time_gm);
strftime(time_str, sizeof(time_str), KNOT_LOG_TIME_FORMAT, &time_gm);
log_zone_info(zone->name, "DNSSEC, next signing on %s", time_str);
time_t now = time(NULL);
time_t ignore = -1;
// schedule
conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
zone_events_schedule_at(zone, ZONE_EVENT_DNSSEC, refresh_at);
zone_events_schedule_at(zone,
ZONE_EVENT_DNSSEC, dnssec_refresh,
ZONE_EVENT_NOTIFY, zone_changed ? now : ignore,
ZONE_EVENT_FLUSH, conf_int(&val) == 0 ? now : ignore
);
}
int event_dnssec(conf_t *conf, zone_t *zone)
......@@ -110,16 +100,9 @@ int event_dnssec(conf_t *conf, zone_t *zone)
update_cleanup(&a_ctx);
}
// Schedule dependent events.
schedule_dnssec(zone, refresh_at);
if (zone_changed) {
zone_events_schedule(zone, ZONE_EVENT_NOTIFY, ZONE_EVENT_NOW);
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);
}
}
// Schedule dependent events
log_dnssec_next(zone->name, refresh_at);
reschedule(conf, zone, refresh_at, zone_changed);
done:
changeset_clear(&ch);
......
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