diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:50 +0000 |
commit | def92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch) | |
tree | 2ef34b9ad8bb9a9220e05d60352558b15f513894 /netwerk/dns/nsHostResolver.cpp | |
parent | Adding debian version 125.0.3-1. (diff) | |
download | firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/dns/nsHostResolver.cpp')
-rw-r--r-- | netwerk/dns/nsHostResolver.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index ad28cbb284..b74b974041 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -1490,6 +1490,18 @@ nsHostResolver::LookupStatus nsHostResolver::CompleteLookup( aReason, aTRRRequest, lock); } +namespace { +class NetAddrIPv6FirstComparator { + public: + static bool Equals(const NetAddr& aLhs, const NetAddr& aRhs) { + return aLhs.raw.family == aRhs.raw.family; + } + static bool LessThan(const NetAddr& aLhs, const NetAddr& aRhs) { + return aLhs.raw.family > aRhs.raw.family; + } +}; +} // namespace + nsHostResolver::LookupStatus nsHostResolver::CompleteLookupLocked( nsHostRecord* rec, nsresult status, AddrInfo* aNewRRSet, bool pb, const nsACString& aOriginsuffix, TRRSkippedReason aReason, @@ -1601,6 +1613,16 @@ nsHostResolver::LookupStatus nsHostResolver::CompleteLookupLocked( old_addr_info = std::move(newRRSet); } addrRec->negative = !addrRec->addr_info; + + if (addrRec->addr_info && StaticPrefs::network_dns_preferIPv6() && + addrRec->addr_info->Addresses().Length() > 1 && + addrRec->addr_info->Addresses()[0].IsIPAddrV4()) { + // Sort IPv6 addresses first. + auto builder = addrRec->addr_info->Build(); + builder.SortAddresses(NetAddrIPv6FirstComparator()); + addrRec->addr_info = builder.Finish(); + } + PrepareRecordExpirationAddrRecord(addrRec); } @@ -1673,6 +1695,15 @@ nsHostResolver::LookupStatus nsHostResolver::CompleteLookupByTypeLocked( MOZ_ASSERT(rec->pb == pb); MOZ_ASSERT(!rec->IsAddrRecord()); + if (rec->LoadNative()) { + // If this was resolved using the native resolver + // we also need to update the global count. + if (rec->LoadUsingAnyThread()) { + mActiveAnyThreadCount--; + rec->StoreUsingAnyThread(false); + } + } + RefPtr<TypeHostRecord> typeRec = do_QueryObject(rec); MOZ_ASSERT(typeRec); |