diff options
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); |