mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 11:19:59 -04:00
Include disptype and transport in dispatch hash key
Move disptype and transport into dispatch_hash() and dispatch_match()
so that the match function is the single source of truth for whether
two TCP dispatches are interchangeable. This replaces the post-loop
disptype filter in dispatch_gettcp() and makes the disptype field in
struct dispatch_key actually used.
(cherry picked from commit 4654796683)
This commit is contained in:
parent
abe201bac3
commit
5588f37baa
1 changed files with 16 additions and 10 deletions
|
|
@ -1137,12 +1137,21 @@ struct dispatch_key {
|
|||
|
||||
static uint32_t
|
||||
dispatch_hash(struct dispatch_key *key) {
|
||||
uint32_t hashval = isc_sockaddr_hash(key->peer, false);
|
||||
if (key->local) {
|
||||
hashval ^= isc_sockaddr_hash(key->local, true);
|
||||
}
|
||||
isc_hash32_t hash;
|
||||
|
||||
return hashval;
|
||||
isc_hash32_init(&hash);
|
||||
|
||||
isc_sockaddr_hash_ex(&hash, key->peer, false);
|
||||
if (key->local != NULL) {
|
||||
isc_sockaddr_hash_ex(&hash, key->local, true);
|
||||
}
|
||||
if (key->transport != NULL) {
|
||||
uintptr_t transport = (uintptr_t)key->transport;
|
||||
isc_hash32_hash(&hash, &transport, sizeof(transport), true);
|
||||
}
|
||||
isc_hash32_hash(&hash, &key->disptype, sizeof(key->disptype), true);
|
||||
|
||||
return isc_hash32_finalize(&hash);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -1160,7 +1169,8 @@ dispatch_match(struct cds_lfht_node *node, const void *key0) {
|
|||
peer = disp->peer;
|
||||
}
|
||||
|
||||
return isc_sockaddr_equal(&peer, key->peer) &&
|
||||
return disp->disptype == key->disptype &&
|
||||
isc_sockaddr_equal(&peer, key->peer) &&
|
||||
disp->transport == key->transport &&
|
||||
(key->local == NULL || isc_sockaddr_equal(&local, key->local));
|
||||
}
|
||||
|
|
@ -1194,10 +1204,6 @@ dispatch_gettcp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *localaddr,
|
|||
INSIST(disp->tid == isc_tid());
|
||||
INSIST(disp->socktype == isc_socktype_tcp);
|
||||
|
||||
if (disp->disptype != disptype) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (disp->state) {
|
||||
case DNS_DISPATCHSTATE_NONE:
|
||||
/* A dispatch in indeterminate state, skip it */
|
||||
|
|
|
|||
Loading…
Reference in a new issue