Commit ece43b45 authored by Lubos Slovak's avatar Lubos Slovak

Cleanup after IXFR fail, refactoring, fixes.

- Copying node and copying RRSet separated to new functions.
- Removing empty RRSet from node.
- Various fixes of API usage.

refs #1034 @20m, #936 @2h
parent a7abf624
......@@ -546,14 +546,11 @@ int dnslib_node_compare(dnslib_node_t *node1, dnslib_node_t *node2)
int dnslib_node_deep_copy(const dnslib_node_t *from, dnslib_node_t **to)
{
// create new node
*to = dnslib_node_new(from->owner, from->parent);
*to = dnslib_node_new(from->owner, from->parent, from->flags);
if (*to == NULL) {
return DNSLIB_ENOMEM;
}
// copy flags
(*to)->flags = from->flags;
// copy references
(*to)->parent = from->parent;
(*to)->nsec3_node = from->nsec3_node;
......
......@@ -147,7 +147,7 @@ static int test_zone_add_node(dnslib_zone_t *zone, int nsec3)
note("Inserting into NULL zone...\n");
dnslib_node_t *node = dnslib_node_new(&test_nodes_good[0].owner,
test_nodes_good[0].parent);
test_nodes_good[0].parent, 0);
if (node == NULL) {
diag("zone: Could not create node.");
return 0;
......
......@@ -516,7 +516,7 @@ static int dnslib_zone_contents_find_in_tree(dnslib_zone_tree_t *tree,
dnslib_node_t **node,
dnslib_node_t **previous)
{
assert(zone != NULL);
assert(tree != NULL);
assert(name != NULL);
assert(node != NULL);
assert(previous != NULL);
......@@ -535,12 +535,12 @@ static int dnslib_zone_contents_find_in_tree(dnslib_zone_tree_t *tree,
// set the previous node of the found node
assert(exact_match);
assert(found != NULL);
*previous = dnslib_node_previous(found);
*previous = dnslib_node_get_previous(found);
} else {
// otherwise check if the previous node is not an empty
// non-terminal
*previous = (dnslib_node_rrset_count(prev) == 0)
? dnslib_node_previous(prev)
? dnslib_node_get_previous(prev)
: prev;
}
......@@ -1410,8 +1410,12 @@ DEBUG_DNSLIB_ZONE(
return DNSLIB_EBADZONE;
}
int exact_match = dnslib_zone_contents_find_in_tree(zone, name, node,
previous);
dnslib_node_t *found = NULL, *prev = NULL;
int exact_match = dnslib_zone_contents_find_in_tree(zone->nodes, name,
&found, &prev);
*node = found;
*previous = prev;
DEBUG_DNSLIB_ZONE(
char *name_str = (*node) ? dnslib_dname_to_str((*node)->owner)
......@@ -1472,7 +1476,7 @@ dnslib_node_t *dnslib_zone_contents_get_previous(
return NULL;
}
const dnslib_node_t *found = NULL, *prev = NULL;
dnslib_node_t *found = NULL, *prev = NULL;
(void)dnslib_zone_contents_find_in_tree(zone->nodes, name, &found,
&prev);
......@@ -1498,10 +1502,10 @@ dnslib_node_t *dnslib_zone_contents_get_previous_nsec3(
return NULL;
}
const dnslib_node_t *found = NULL, *prev = NULL;
dnslib_node_t *found = NULL, *prev = NULL;
(void)dnslib_zone_contents_find_in_tree(zone->nsec3_nodes, name, &found,
prev);
&prev);
assert(prev != NULL);
return prev;
......
......@@ -273,7 +273,8 @@ int dnslib_zone_add_node(dnslib_zone_t *zone, dnslib_node_t *node,
}
return dnslib_zone_contents_add_node(zone->contents, node,
create_parents, use_domain_table);
create_parents, 0,
use_domain_table);
// if (zone == NULL || node == NULL || zone->contents == NULL) {
// return DNSLIB_EBADARG;
// }
......
This diff is collapsed.
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