Commit c49df877 authored by Daniel Salzman's avatar Daniel Salzman

ctl: allow empty zone transaction commit doing nothing

parent f7f4b94a
......@@ -417,6 +417,15 @@ static int zone_txn_begin(zone_t *zone, ctl_args_t *args)
return KNOT_EOK;
}
static void zone_txn_update_clear(zone_t *zone)
{
assert(zone->control_update);
zone_update_clear(zone->control_update);
free(zone->control_update);
zone->control_update = NULL;
}
static int zone_txn_commit(zone_t *zone, ctl_args_t *args)
{
UNUSED(args);
......@@ -425,6 +434,15 @@ static int zone_txn_commit(zone_t *zone, ctl_args_t *args)
return KNOT_TXN_ENOTEXISTS;
}
// NOOP if empty changeset/contents.
if (((zone->control_update->flags & UPDATE_INCREMENTAL) &&
changeset_empty(&zone->control_update->change)) ||
((zone->control_update->flags & UPDATE_FULL) &&
zone_contents_is_empty(zone->control_update->new_cont))) {
zone_txn_update_clear(zone);
return KNOT_EOK;
}
// Sign update.
conf_val_t val = conf_zone_get(conf(), C_DNSSEC_SIGNING, zone->name);
bool dnssec_enable = (zone->control_update->flags & UPDATE_SIGN) && conf_bool(&val);
......@@ -432,9 +450,7 @@ static int zone_txn_commit(zone_t *zone, ctl_args_t *args)
zone_sign_reschedule_t resch = { 0 };
int ret = knot_dnssec_sign_update(zone->control_update, &resch);
if (ret != KNOT_EOK) {
zone_update_clear(zone->control_update);
free(zone->control_update);
zone->control_update = NULL;
zone_txn_update_clear(zone);
return ret;
}
log_dnssec_next(zone->name, (time_t)resch.next_sign);
......@@ -451,9 +467,7 @@ static int zone_txn_commit(zone_t *zone, ctl_args_t *args)
return ret;
}
zone_update_clear(zone->control_update);
free(zone->control_update);
zone->control_update = NULL;
zone_txn_update_clear(zone);
zone_events_schedule_now(zone, ZONE_EVENT_NOTIFY);
......@@ -468,9 +482,7 @@ static int zone_txn_abort(zone_t *zone, ctl_args_t *args)
return KNOT_TXN_ENOTEXISTS;
}
zone_update_clear(zone->control_update);
free(zone->control_update);
zone->control_update = NULL;
zone_txn_update_clear(zone);
return KNOT_EOK;
}
......
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