chg: nil: Improve reuse of outgoing TCP connections

This MR is a prerequisite for !8348.

It intentionally does not have a changelog entry associated with it, to
prevent making a false impression of improving connection reuse **for
existing code**.  It will only make a difference once !8348 gets merged
(and even then, only if the new `ISC_SOCKET_DETAILS` macro will be set
during build).  That's because `isc_nmhandle_localaddr()` currently
simply returns `handle->local` and its return value will only be set to
the actual address the socket is bound to with !8348 in place.

Note that `dns_dispatch_gettcp()` is currently only used by the
`dns_request` API, so this MR's potential for introducing new breakage
is relatively low.

Closes #4693

Merge branch '4693-improve-reuse-of-outgoing-tcp-connections' into 'main'

See merge request isc-projects/bind9!8972
This commit is contained in:
Michał Kępień 2024-12-29 11:31:29 +00:00
commit dc90e977fc

View file

@ -1152,20 +1152,11 @@ static int
dispatch_match(struct cds_lfht_node *node, const void *key0) {
dns_dispatch_t *disp = caa_container_of(node, dns_dispatch_t, ht_node);
const struct dispatch_key *key = key0;
isc_sockaddr_t local;
isc_sockaddr_t peer;
if (disp->handle != NULL) {
local = isc_nmhandle_localaddr(disp->handle);
peer = isc_nmhandle_peeraddr(disp->handle);
} else {
local = disp->local;
peer = disp->peer;
}
return isc_sockaddr_equal(&peer, key->peer) &&
disp->transport == key->transport &&
(key->local == NULL || isc_sockaddr_equal(&local, key->local));
return disp->transport == key->transport &&
isc_sockaddr_equal(&disp->peer, key->peer) &&
(key->local == NULL ||
isc_sockaddr_equal(&disp->local, key->local));
}
isc_result_t