Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
94ad27de
Commit
94ad27de
authored
Apr 08, 2014
by
Jan Kadlec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new_node: Added more comments for changeset processing.
parent
dd75a94e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
src/knot/updates/xfr-in.c
src/knot/updates/xfr-in.c
+23
-4
No files found.
src/knot/updates/xfr-in.c
View file @
94ad27de
...
...
@@ -44,6 +44,11 @@
static
void
rrs_list_clear
(
list_t
*
l
,
mm_ctx_t
*
mm
)
{
/*
* Frees data that are in the tree that will not be used, these are:
* - actual data inside knot_rrs_t. (the rest is part of the node)
* - arrays allocated for additional nodes. (nodes are kept)
*/
ptrnode_t
*
n
;
node_t
*
nxt
;
WALK_LIST_DELSAFE
(
n
,
nxt
,
*
l
)
{
...
...
@@ -670,6 +675,7 @@ void xfrin_rollback_update(knot_changesets_t *chgs,
static
int
xfrin_replace_rrs_with_copy
(
knot_node_t
*
node
,
uint16_t
type
)
{
// Find data to copy.
struct
rr_data
*
data
=
NULL
;
for
(
uint16_t
i
=
0
;
i
<
node
->
rrset_count
;
++
i
)
{
if
(
node
->
rrs
[
i
].
type
==
type
)
{
...
...
@@ -677,6 +683,8 @@ static int xfrin_replace_rrs_with_copy(knot_node_t *node,
}
}
assert
(
data
);
// Create new data.
knot_rrs_t
*
rrs
=
&
data
->
rrs
;
void
*
copy
=
malloc
(
knot_rrs_size
(
rrs
));
if
(
copy
==
NULL
)
{
...
...
@@ -685,8 +693,12 @@ static int xfrin_replace_rrs_with_copy(knot_node_t *node,
memcpy
(
copy
,
rrs
->
data
,
knot_rrs_size
(
rrs
));
// Clear additional from node in new tree.
/*
* Clear additional array from node in new tree. It's callers
* responsibility to store it for cleanup.
*/
data
->
additional
=
NULL
;
// Store new data into node RRS.
rrs
->
data
=
copy
;
return
KNOT_EOK
;
...
...
@@ -703,10 +715,12 @@ static void clear_new_rrs(knot_node_t *node, uint16_t type)
static
bool
can_remove
(
const
knot_node_t
*
node
,
const
knot_rrset_t
*
rr
)
{
if
(
node
==
NULL
)
{
// Node does not exist, cannot remove anything.
return
false
;
}
const
knot_rrs_t
*
node_rrs
=
knot_node_rrs
(
node
,
rr
->
type
);
if
(
node_rrs
==
NULL
)
{
// Node does not have this type at all.
return
false
;
}
...
...
@@ -714,9 +728,12 @@ static bool can_remove(const knot_node_t *node, const knot_rrset_t *rr)
for
(
uint16_t
i
=
0
;
i
<
rr
->
rrs
.
rr_count
;
++
i
)
{
knot_rr_t
*
rr_cmp
=
knot_rrs_rr
(
&
rr
->
rrs
,
i
);
if
(
knot_rrs_member
(
node_rrs
,
rr_cmp
,
compare_ttls
))
{
// At least one RR matches.
return
true
;
}
}
// Node does have the type, but no RRs match.
return
false
;
}
...
...
@@ -766,6 +783,7 @@ static int remove_rr(knot_node_t *node, const knot_rrset_t *rr,
}
knot_rrs_t
*
changed_rrs
=
knot_node_get_rrs
(
node
,
rr
->
type
);
// Subtract changeset RRS from node RRS.
ret
=
knot_rrs_subtract
(
changed_rrs
,
&
rr
->
rrs
,
NULL
);
if
(
ret
!=
KNOT_EOK
)
{
clear_new_rrs
(
node
,
rr
->
type
);
...
...
@@ -773,13 +791,14 @@ static int remove_rr(knot_node_t *node, const knot_rrset_t *rr,
}
if
(
changed_rrs
->
rr_count
>
0
)
{
// Subtraction left some data in RRSet, store it for rollback.
ret
=
add_new_data
(
chset
,
changed_rrs
->
data
);
if
(
ret
!=
KNOT_EOK
)
{
knot_rrs_clear
(
changed_rrs
,
NULL
);
return
ret
;
}
}
else
{
// R
emoved last RR in RRSet, remove it from node
.
// R
RSet is empty now, remove it from node, all data freed
.
knot_node_remove_rrset
(
node
,
rr
->
type
);
}
...
...
@@ -823,7 +842,7 @@ static int add_rr(knot_node_t *node, const knot_rrset_t *rr,
return
ret
;
}
// Store old RRS for cleanup.
// Store old RRS
and additional
for cleanup.
ret
=
add_old_data
(
chset
,
old_data
,
old_additional
);
if
(
ret
!=
KNOT_EOK
)
{
clear_new_rrs
(
node
,
rr
->
type
);
...
...
@@ -845,8 +864,8 @@ static int add_rr(knot_node_t *node, const knot_rrset_t *rr,
}
}
// Get changed RRS and store for possible rollback.
knot_rrs_t
*
rrs
=
knot_node_get_rrs
(
node
,
rr
->
type
);
// Store new RRS for rollback
int
ret
=
add_new_data
(
chset
,
rrs
->
data
);
if
(
ret
!=
KNOT_EOK
)
{
knot_rrs_clear
(
rrs
,
NULL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment