2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-04 00:25:29 +00:00

Merge branch '2953-rework-the-fetchctx_t-reference-counting' into 'main'

Rewrite the fetchctx_t reference counting

Closes #2953

See merge request isc-projects/bind9!5500
This commit is contained in:
Evan Hunt
2021-10-18 22:08:45 +00:00
4 changed files with 317 additions and 456 deletions

View File

@@ -1,3 +1,8 @@
5745. [bug] Fetch context objects now use attach/detach
semantics to make it easier to find and debug
reference-counting errors, and several such errors
have been fixed. [GL #2953]
5744. [func] The network manager is now used for netlink sockets 5744. [func] The network manager is now used for netlink sockets
to monitor network interface changes. This was the to monitor network interface changes. This was the
last remaining use of the old isc_socket and last remaining use of the old isc_socket and

View File

@@ -909,7 +909,6 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
int addr_bucket; int addr_bucket;
bool new_addresses_added; bool new_addresses_added;
dns_rdatatype_t rdtype; dns_rdatatype_t rdtype;
unsigned int findoptions;
dns_adbnamehooklist_t *hookhead; dns_adbnamehooklist_t *hookhead;
INSIST(DNS_ADBNAME_VALID(adbname)); INSIST(DNS_ADBNAME_VALID(adbname));
@@ -918,11 +917,6 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
rdtype = rdataset->type; rdtype = rdataset->type;
INSIST((rdtype == dns_rdatatype_a) || (rdtype == dns_rdatatype_aaaa)); INSIST((rdtype == dns_rdatatype_a) || (rdtype == dns_rdatatype_aaaa));
if (rdtype == dns_rdatatype_a) {
findoptions = DNS_ADBFIND_INET;
} else {
findoptions = DNS_ADBFIND_INET6;
}
addr_bucket = DNS_ADB_INVALIDBUCKET; addr_bucket = DNS_ADB_INVALIDBUCKET;
new_addresses_added = false; new_addresses_added = false;
@@ -946,24 +940,12 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
INSIST(nh == NULL); INSIST(nh == NULL);
nh = new_adbnamehook(adb, NULL); nh = new_adbnamehook(adb, NULL);
if (nh == NULL) {
adbname->partial_result |= findoptions;
result = ISC_R_NOMEMORY;
goto fail;
}
foundentry = find_entry_and_lock(adb, &sockaddr, &addr_bucket, foundentry = find_entry_and_lock(adb, &sockaddr, &addr_bucket,
now); now);
if (foundentry == NULL) { if (foundentry == NULL) {
dns_adbentry_t *entry; dns_adbentry_t *entry;
entry = new_adbentry(adb); entry = new_adbentry(adb);
if (entry == NULL) {
adbname->partial_result |= findoptions;
result = ISC_R_NOMEMORY;
goto fail;
}
entry->sockaddr = sockaddr; entry->sockaddr = sockaddr;
entry->refcnt = 1; entry->refcnt = 1;
entry->nh = 1; entry->nh = 1;
@@ -996,7 +978,6 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
result = dns_rdataset_next(rdataset); result = dns_rdataset_next(rdataset);
} }
fail:
if (nh != NULL) { if (nh != NULL) {
free_adbnamehook(adb, &nh); free_adbnamehook(adb, &nh);
} }
@@ -2928,8 +2909,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
* Possibilities: Note that these are not always exclusive. * Possibilities: Note that these are not always exclusive.
* *
* No name found. In this case, allocate a new name header and * No name found. In this case, allocate a new name header and
* an initial namehook or two. If any of these allocations * an initial namehook or two.
* fail, clean up and return ISC_R_NOMEMORY.
* *
* Name found, valid addresses present. Allocate one addrinfo * Name found, valid addresses present. Allocate one addrinfo
* structure for each found and append it to the linked list * structure for each found and append it to the linked list
@@ -2942,9 +2922,6 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
*/ */
find = new_adbfind(adb); find = new_adbfind(adb);
if (find == NULL) {
return (ISC_R_NOMEMORY);
}
find->port = port; find->port = port;
@@ -2988,11 +2965,6 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
check_stale_name(adb, bucket, now); check_stale_name(adb, bucket, now);
adbname = new_adbname(adb, name); adbname = new_adbname(adb, name);
if (adbname == NULL) {
RUNTIME_CHECK(!free_adbfind(adb, &find));
result = ISC_R_NOMEMORY;
goto out;
}
link_name(adb, bucket, adbname); link_name(adb, bucket, adbname);
if (FIND_HINTOK(find)) { if (FIND_HINTOK(find)) {
adbname->flags |= NAME_HINT_OK; adbname->flags |= NAME_HINT_OK;
@@ -4064,10 +4036,6 @@ fetch_name(dns_adbname_t *adbname, bool start_at_zone, unsigned int depth,
} }
fetch = new_adbfetch(adb); fetch = new_adbfetch(adb);
if (fetch == NULL) {
result = ISC_R_NOMEMORY;
goto cleanup;
}
fetch->depth = depth; fetch->depth = depth;
/* /*
@@ -4137,11 +4105,6 @@ dns_adb_marklame(dns_adb_t *adb, dns_adbaddrinfo_t *addr,
goto unlock; goto unlock;
} }
li = new_adblameinfo(adb, qname, qtype); li = new_adblameinfo(adb, qname, qtype);
if (li == NULL) {
result = ISC_R_NOMEMORY;
goto unlock;
}
li->lame_timer = expire_time; li->lame_timer = expire_time;
ISC_LIST_PREPEND(addr->entry->lameinfo, li, plink); ISC_LIST_PREPEND(addr->entry->lameinfo, li, plink);
@@ -4515,10 +4478,6 @@ dns_adb_findaddrinfo(dns_adb_t *adb, const isc_sockaddr_t *sa,
* We don't know anything about this address. * We don't know anything about this address.
*/ */
entry = new_adbentry(adb); entry = new_adbentry(adb);
if (entry == NULL) {
result = ISC_R_NOMEMORY;
goto unlock;
}
entry->sockaddr = *sa; entry->sockaddr = *sa;
link_entry(adb, bucket, entry); link_entry(adb, bucket, entry);
DP(ENTER_LEVEL, "findaddrinfo: new entry %p", entry); DP(ENTER_LEVEL, "findaddrinfo: new entry %p", entry);

View File

@@ -65,11 +65,6 @@
#define RBT_HASH_NEXTTABLE(hindex) ((hindex == 0) ? 1 : 0) #define RBT_HASH_NEXTTABLE(hindex) ((hindex == 0) ? 1 : 0)
#ifdef RBT_MEM_TEST
#undef RBT_HASH_SIZE
#define RBT_HASH_SIZE 2 /*%< To give the reallocation code a workout. */
#endif /* ifdef RBT_MEM_TEST */
#define GOLDEN_RATIO_32 0x61C88647 #define GOLDEN_RATIO_32 0x61C88647
#define HASHSIZE(bits) (UINT64_C(1) << (bits)) #define HASHSIZE(bits) (UINT64_C(1) << (bits))

File diff suppressed because it is too large Load Diff