Commit 3848779b authored by Jan Kadlec's avatar Jan Kadlec

Review based changes to changesets.

Refs #102
parent 946ae3db
......@@ -867,7 +867,6 @@ static int zones_load_changesets(const knot_zone_t *zone,
/* Next node. */
found_to = chs->serial_to;
++dst->count;
++n;
/*! \todo Check consistency. */
......@@ -947,7 +946,7 @@ static int zones_journal_apply(knot_zone_t *zone)
/*! \todo Check what should be the upper bound. */
int ret = zones_load_changesets(zone, chsets, serial, serial - 1);
if (ret == KNOT_EOK || ret == KNOT_ERANGE) {
if (chsets->count > 0) {
if (!EMPTY_LIST(chsets->sets)) {
/* Apply changesets. */
log_server_info("Applying '%zu' changesets from journal "
"to zone '%s'.\n",
......@@ -1632,7 +1631,10 @@ static int zones_process_update_auth(knot_zone_t *zone,
/* 1) Process the UPDATE packet, apply to zone, create changesets. */
dbg_zones_verb("Processing UPDATE packet.\n");
chgsets->count = 1; /* DU is represented by a single chset. */
/* DU is represented by a single chset. */
if (knot_changesets_create_changeset(chgsets) == NULL) {
return KNOT_ERROR;
}
knot_zone_contents_t *new_contents = NULL;
ret = knot_ns_process_update2(knot_packet_query(resp),
......
......@@ -2948,7 +2948,7 @@ static int ns_ixfr_from_zone(knot_ns_xfr_t *xfr)
}
}
if (chgsets->count > 0) {
if (!EMPTY_LIST(chgsets->sets)) {
res = ns_ixfr_put_rrset(xfr, zone_soa);
}
......@@ -4349,7 +4349,7 @@ int knot_ns_process_update2(const knot_packet_t *query,
{
/*! \todo Implement. */
if (query == NULL || old_contents == NULL || chgs == NULL ||
chgs->count == 0 || new_contents == NULL || rcode == NULL) {
EMPTY_LIST(chgs->sets) || new_contents == NULL || rcode == NULL) {
return KNOT_EINVAL;
}
......
......@@ -112,12 +112,14 @@ knot_changeset_t *knot_changesets_create_changeset(knot_changesets_t *ch)
// Insert into list of sets
add_tail(&ch->sets, (node *)set);
++ch->count;
return set;
}
knot_changeset_t *knot_changesets_get_last(const knot_changesets_t *chs)
{
if (chs == NULL || chs->count == 0) {
if (chs == NULL || EMPTY_LIST(chs->sets)) {
return NULL;
}
......
......@@ -1755,7 +1755,7 @@ static int knot_ddns_process_rem_rr(const knot_rrset_t *rr,
*/
ret = knot_changes_add_rrset(changes, rr_remove, KNOT_CHANGES_OLD);
if (ret != KNOT_EOK) {
knot_rrset_free(&rr_remove);
knot_rrset_deep_free(&rr_remove, 1, 1);
dbg_ddns_detail("Failed to add data to changes.\n");
return ret;
}
......
......@@ -1068,7 +1068,7 @@ int xfrin_process_ixfr_packet(knot_ns_xfr_t *xfr)
if (state != -1) {
dbg_xfrin_detail("State is not -1, deciding...\n");
// there should be at least one started changeset right now
if ((*chs)->count <= 0) {
if (EMPTY_LIST((*chs)->sets)) {
knot_rrset_deep_free(&rr, 1, 1);
ret = KNOT_EMALF;
goto cleanup;
......@@ -1148,7 +1148,6 @@ dbg_xfrin_exec_verb(
}
knot_changeset_add_soa(cur, rr, KNOT_CHANGESET_REMOVE);
(*chs)->count++;
// change state to REMOVE
state = KNOT_CHANGESET_REMOVE;
}
......@@ -2858,7 +2857,7 @@ int xfrin_apply_changesets(knot_zone_t *zone,
knot_changesets_t *chsets,
knot_zone_contents_t **new_contents)
{
if (zone == NULL || chsets == NULL || chsets->count == 0
if (zone == NULL || chsets == NULL || EMPTY_LIST(chsets->sets)
|| new_contents == NULL) {
return KNOT_EINVAL;
}
......
......@@ -1028,8 +1028,6 @@ int knot_zone_diff_create_changesets(const knot_zone_contents_t *z1,
return ret;
}
(*changesets)->count = 1;
dbg_zonediff("Changesets created successfully!\n");
dbg_zonediff_detail("Changeset dump:\n");
dbg_zonediff_exec_detail(
......
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