mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 14:00:00 -04:00
Extract the do-while loop in dns__zone_updatesigs() into a separate function
The do-while loop in dns__zone_updatesigs() is hard to follow due to heavy nesting and the 'tuple' variable also being used in the outer for loop. Add a comment to explain the purpose of the do-while loop. Extract it into a separate function to decrease indentation and prevent using 'tuple' in two different loops.
This commit is contained in:
parent
3c40aa004a
commit
31cdf770a4
1 changed files with 27 additions and 11 deletions
|
|
@ -7288,6 +7288,25 @@ need_nsec_chain(dns_db_t *db, dns_dbversion_t *ver,
|
|||
return (result);
|
||||
}
|
||||
|
||||
/*%
|
||||
* Remove all tuples with the same name and type as 'cur' from 'src' and append
|
||||
* them to 'dst'.
|
||||
*/
|
||||
static void
|
||||
move_matching_tuples(dns_difftuple_t *cur, dns_diff_t *src, dns_diff_t *dst) {
|
||||
do {
|
||||
dns_difftuple_t *next = ISC_LIST_NEXT(cur, link);
|
||||
while (next != NULL &&
|
||||
(cur->rdata.type != next->rdata.type ||
|
||||
!dns_name_equal(&cur->name, &next->name)))
|
||||
next = ISC_LIST_NEXT(next, link);
|
||||
ISC_LIST_UNLINK(src->tuples, cur, link);
|
||||
dns_diff_appendminimal(dst, &cur);
|
||||
INSIST(cur == NULL);
|
||||
cur = next;
|
||||
} while (cur != NULL);
|
||||
}
|
||||
|
||||
/*%
|
||||
* Add/remove DNSSEC signatures for the list of "raw" zone changes supplied in
|
||||
* 'diff'. Gradually remove tuples from 'diff' and append them to 'zonediff'
|
||||
|
|
@ -7337,17 +7356,14 @@ dns__zone_updatesigs(dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *version,
|
|||
return (result);
|
||||
}
|
||||
|
||||
do {
|
||||
dns_difftuple_t *next = ISC_LIST_NEXT(tuple, link);
|
||||
while (next != NULL &&
|
||||
(tuple->rdata.type != next->rdata.type ||
|
||||
!dns_name_equal(&tuple->name, &next->name)))
|
||||
next = ISC_LIST_NEXT(next, link);
|
||||
ISC_LIST_UNLINK(diff->tuples, tuple, link);
|
||||
dns_diff_appendminimal(zonediff->diff, &tuple);
|
||||
INSIST(tuple == NULL);
|
||||
tuple = next;
|
||||
} while (tuple != NULL);
|
||||
/*
|
||||
* Signature changes for all RRs with name tuple->name and type
|
||||
* tuple->rdata.type were appended to zonediff->diff. Now we
|
||||
* remove all the "raw" changes with the same name and type
|
||||
* from diff (so that they are not processed by this loop
|
||||
* again) and append them to zonediff so that they get applied.
|
||||
*/
|
||||
move_matching_tuples(tuple, diff, zonediff->diff);
|
||||
}
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue