mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Rewrite dns_resolver and dns_request to use netmgr timeouts
- The `timeout_action` parameter to dns_dispatch_addresponse() been replaced with a netmgr callback that is called when a dispatch read times out. this callback may optionally reset the read timer and resume reading. - Added a function to convert isc_interval to milliseconds; this is used to translate fctx->interval into a value that can be passed to dns_dispatch_addresponse() as the timeout. - Note that netmgr timeouts are accurate to the millisecond, so code to check whether a timeout has been reached cannot rely on microsecond accuracy. - If serve-stale is configured, then a timeout received by the resolver may trigger it to return stale data, and then resume waiting for the read timeout. this is no longer based on a separate stale timer. - The code for canceling requests in request.c has been altered so that it can run asynchronously. - TCP timeout events apply to the dispatch, which may be shared by multiple queries. since in the event of a timeout we have no query ID to use to identify the resp we wanted, we now just send the timeout to the oldest query that was pending. - There was some additional refactoring in the resolver: combining fctx_join() and fctx_try_events() into one function to reduce code duplication, and using fixednames in fetchctx and fetchevent. - Incidental fix: new_adbaddrinfo() can't return NULL anymore, so the code can be simplified.
This commit is contained in:
@@ -2237,11 +2237,9 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find,
|
||||
find->options |= DNS_ADBFIND_LAMEPRUNED;
|
||||
goto nextv4;
|
||||
}
|
||||
|
||||
addrinfo = new_adbaddrinfo(adb, entry, find->port);
|
||||
if (addrinfo == NULL) {
|
||||
find->partial_result |= DNS_ADBFIND_INET;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Found a valid entry. Add it to the find's list.
|
||||
*/
|
||||
@@ -2275,10 +2273,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find,
|
||||
goto nextv6;
|
||||
}
|
||||
addrinfo = new_adbaddrinfo(adb, entry, find->port);
|
||||
if (addrinfo == NULL) {
|
||||
find->partial_result |= DNS_ADBFIND_INET6;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Found a valid entry. Add it to the find's list.
|
||||
*/
|
||||
@@ -2292,7 +2287,6 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find,
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (bucket != DNS_ADB_INVALIDBUCKET) {
|
||||
UNLOCK(&adb->entrylocks[bucket]);
|
||||
}
|
||||
@@ -3962,8 +3956,7 @@ fetch_callback(isc_task_t *task, isc_event_t *ev) {
|
||||
dev->rdataset->ttl = ttlclamp(dev->rdataset->ttl);
|
||||
clean_target(adb, &name->target);
|
||||
name->expire_target = INT_MAX;
|
||||
result = set_target(adb, &name->name,
|
||||
dns_fixedname_name(&dev->foundname),
|
||||
result = set_target(adb, &name->name, dev->foundname,
|
||||
dev->rdataset, &name->target);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
DP(NCACHE_LEVEL,
|
||||
@@ -4533,12 +4526,8 @@ dns_adb_findaddrinfo(dns_adb_t *adb, const isc_sockaddr_t *sa,
|
||||
|
||||
port = isc_sockaddr_getport(sa);
|
||||
addr = new_adbaddrinfo(adb, entry, port);
|
||||
if (addr == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
} else {
|
||||
inc_entry_refcnt(adb, entry, false);
|
||||
*addrp = addr;
|
||||
}
|
||||
inc_entry_refcnt(adb, entry, false);
|
||||
*addrp = addr;
|
||||
|
||||
unlock:
|
||||
UNLOCK(&adb->entrylocks[bucket]);
|
||||
|
Reference in New Issue
Block a user