Commit ba0aa4a2 authored by Jan Kadlec's avatar Jan Kadlec

Merge fixups, backported rollbacks from master/zones.c

parent 4761990e
......@@ -1099,23 +1099,29 @@ int xfrin_apply_changesets_directly(zone_contents_t *contents,
const bool master = true; // Only DNSSEC changesets are applied directly.
int ret = xfrin_apply_changeset(contents, set, master);
if (ret != KNOT_EOK) {
xfrin_cleanup_successful_update(chsets);
return ret;
}
}
return xfrin_finalize_updated_zone(contents, true);
int ret = xfrin_finalize_updated_zone(contents, true);
/*
* HACK: Cleanup for successful update is used for both success and fail
* when modifying the zone directly, will fix in new zone API.
*/
xfrin_cleanup_successful_update(chsets);
return ret;
}
/*----------------------------------------------------------------------------*/
/* Post-DDNS application, no need to shallow copy. */
int xfrin_apply_changesets_dnssec_ddns(zone_t *zone,
zone_contents_t *z_new,
int xfrin_apply_changesets_dnssec_ddns(zone_contents_t *z_new,
knot_changesets_t *sec_chsets,
knot_changesets_t *chsets)
{
if (zone == NULL || z_new == NULL ||
sec_chsets == NULL || chsets == NULL) {
if (z_new == NULL || sec_chsets == NULL || chsets == NULL) {
return KNOT_EINVAL;
}
......@@ -1125,7 +1131,6 @@ int xfrin_apply_changesets_dnssec_ddns(zone_t *zone,
/* Apply changes. */
int ret = xfrin_apply_changesets_directly(z_new, sec_chsets);
if (ret != KNOT_EOK) {
xfrin_rollback_update(sec_chsets, &z_new);
dbg_xfrin("Failed to apply changesets to zone: "
"%s\n", knot_strerror(ret));
return ret;
......
......@@ -636,7 +636,7 @@ static zone_node_t *zone_contents_get_nsec3_node(const zone_contents_t *zone,
return n;
}
static int insert_rr(knot_zone_contents_t *z,
static int insert_rr(zone_contents_t *z,
const knot_rrset_t *rr, zone_node_t **n,
bool nsec3)
{
......@@ -771,8 +771,8 @@ static bool rrset_is_nsec3rel(const knot_rrset_t *rr)
== KNOT_RRTYPE_NSEC3));
}
int knot_zone_contents_add_rr(knot_zone_contents_t *z,
const knot_rrset_t *rr, zone_node_t **n)
int zone_contents_add_rr(zone_contents_t *z, const knot_rrset_t *rr,
zone_node_t **n)
{
return insert_rr(z, rr, n, rrset_is_nsec3rel(rr));
}
......
......@@ -91,8 +91,7 @@ int zone_contents_gen_is_new(const zone_contents_t *contents);
void zone_contents_set_gen_old(zone_contents_t *contents);
void zone_contents_set_gen_new(zone_contents_t *contents);
int knot_zone_contents_add_rr(knot_zone_contents_t *z,
const knot_rrset_t *rr, zone_node_t **n);
int zone_contents_add_rr(zone_contents_t *z, const knot_rrset_t *rr, zone_node_t **n);
int zone_contents_remove_node(zone_contents_t *contents, const knot_dname_t *owner);
......
......@@ -115,11 +115,6 @@ int zone_load_journal(zone_contents_t *contents, conf_zone_t *conf)
serial, zone_contents_serial(contents),
knot_strerror(ret));
/* Free changesets and return. */
if (ret == KNOT_EOK) {
xfrin_cleanup_successful_update(chsets);
}
knot_changesets_free(&chsets);
return ret;
}
......
......@@ -158,18 +158,7 @@ int zone_change_commit(zone_contents_t *contents, knot_changesets_t *chset)
}
/* Apply DNSSEC changeset to the new zone. */
int ret = xfrin_apply_changesets_directly(contents, chset);
if (ret == KNOT_EOK) {
ret = xfrin_finalize_updated_zone(contents, true);
}
if (ret == KNOT_EOK) {
/* No need to do rollback, the whole new zone will be
* discarded. */
xfrin_cleanup_successful_update(chset);
}
return ret;
return xfrin_apply_changesets_directly(contents, chset);
}
int zone_change_store(zone_t *zone, knot_changesets_t *chset)
......@@ -207,7 +196,6 @@ int zone_change_apply_and_store(knot_changesets_t *chs,
ret = xfrin_apply_changesets(zone, chs, new_contents);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to apply changesets.\n", msgpref);
/* Free changesets, but not the data. */
knot_changesets_free(&chs);
return ret; // propagate the error above
......@@ -217,7 +205,7 @@ int zone_change_apply_and_store(knot_changesets_t *chs,
ret = zone_change_store(zone, chs);
if (ret != KNOT_EOK) {
log_zone_error("%s Failed to store changesets.\n", msgpref);
xfrin_rollback_update(chs, new_contents);
/* Free changesets, but not the data. */
knot_changesets_free(&chs);
return ret; // propagate the error above
......
......@@ -37,7 +37,7 @@
#include "libknot/rdata.h"
#include "knot/zone/zone-dump.h"
void process_error(const zs_scanner_t *s)
void process_error(zs_scanner_t *s)
{
if (s->stop == true) {
log_zone_error("Fatal error in zone file %s:%"PRIu64": %s "
......@@ -116,7 +116,7 @@ int zcreator_step(zcreator_t *zc, const knot_rrset_t *rr)
}
zone_node_t *node = NULL;
int ret = knot_zone_contents_add_rr(zc->z, rr, &node);
int ret = zone_contents_add_rr(zc->z, rr, &node);
if (ret != KNOT_EOK) {
if (!handle_err(zc, node, rr, ret, zc->master)) {
// Fatal error
......@@ -145,7 +145,7 @@ int zcreator_step(zcreator_t *zc, const knot_rrset_t *rr)
}
/*! \brief Creates RR from parser input, passes it to handling function. */
static void loader_process(const zs_scanner_t *scanner)
static void loader_process(zs_scanner_t *scanner)
{
zcreator_t *zc = scanner->data;
if (zc->ret != KNOT_EOK) {
......
......@@ -41,7 +41,7 @@
/*!
* \brief Empty function which is called if no callback function is specified.
*/
static inline void noop(zs_scanner_t *s)
static inline void noop(const zs_scanner_t *s)
{
(void)s;
}
......
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