# HG changeset patch
# Parent bf6a2107cbc91bae818cb4fd2e98adaa9e27b8ce
# User Dragana Damjanovic
Additional fix for nsHostResolver.
diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -205,21 +205,22 @@ void
nsHostRecord::SetExpiration(const mozilla::TimeStamp& now, unsigned int valid, unsigned int grace)
{
mValidStart = now;
mGraceStart = now + TimeDuration::FromSeconds(valid);
mValidEnd = now + TimeDuration::FromSeconds(valid + grace);
}
void
-nsHostRecord::CopyExpirationTimesFrom(const nsHostRecord *aFromHostRecord)
+nsHostRecord::CopyExpirationTimesAndFlagsFrom(const nsHostRecord *aFromHostRecord)
{
mValidStart = aFromHostRecord->mValidStart;
mValidEnd = aFromHostRecord->mValidEnd;
mGraceStart = aFromHostRecord->mGraceStart;
+ mDoomed = aFromHostRecord->mDoomed;
}
nsHostRecord::~nsHostRecord()
{
Telemetry::Accumulate(Telemetry::DNS_BLACKLIST_COUNT, mBlacklistedCount);
delete addr_info;
delete addr;
}
@@ -848,40 +849,44 @@ nsHostResolver::ResolveHost(const char
"Entry should be resolved or negative.");
LOG((" Trying AF_UNSPEC entry for [%s] af: %s.\n",
host, (af == PR_AF_INET) ? "AF_INET" : "AF_INET6"));
he->rec->addr_info = nullptr;
if (unspecHe->rec->negative) {
he->rec->negative = unspecHe->rec->negative;
- he->rec->CopyExpirationTimesFrom(unspecHe->rec);
+ he->rec->CopyExpirationTimesAndFlagsFrom(unspecHe->rec);
} else if (unspecHe->rec->addr_info) {
// Search for any valid address in the AF_UNSPEC entry
// in the cache (not blacklisted and from the right
// family).
NetAddrElement *addrIter =
unspecHe->rec->addr_info->mAddresses.getFirst();
while (addrIter) {
if ((af == addrIter->mAddress.inet.family) &&
!unspecHe->rec->Blacklisted(&addrIter->mAddress)) {
if (!he->rec->addr_info) {
he->rec->addr_info = new AddrInfo(
unspecHe->rec->addr_info->mHostName,
unspecHe->rec->addr_info->mCanonicalName);
- he->rec->CopyExpirationTimesFrom(unspecHe->rec);
+ he->rec->CopyExpirationTimesAndFlagsFrom(unspecHe->rec);
}
he->rec->addr_info->AddAddress(
new NetAddrElement(*addrIter));
}
addrIter = addrIter->getNext();
}
}
- if (he->rec->HasUsableResult(TimeStamp::NowLoRes(), flags)) {
+ // Now check if we have a new record.
+ if (he->rec->addr_info || he->rec->negative) {
result = he->rec;
+ if (he->rec->negative) {
+ status = NS_ERROR_UNKNOWN_HOST;
+ }
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
METHOD_HIT);
ConditionallyRefreshRecord(he->rec, host);
}
// For AF_INET6, a new lookup means another AF_UNSPEC
// lookup. We have already iterated through the
// AF_UNSPEC addresses, so we mark this record as
// negative.
diff --git a/netwerk/dns/nsHostResolver.h b/netwerk/dns/nsHostResolver.h
--- a/netwerk/dns/nsHostResolver.h
+++ b/netwerk/dns/nsHostResolver.h
@@ -96,17 +96,17 @@ public:
// If a record is in its grace period (and not expired), it will be used
// but a request to refresh it will be made.
mozilla::TimeStamp mGraceStart;
// Convenience function for setting the timestamps above (mValidStart,
// mValidEnd, and mGraceStart). valid and grace are durations in seconds.
void SetExpiration(const mozilla::TimeStamp& now, unsigned int valid,
unsigned int grace);
- void CopyExpirationTimesFrom(const nsHostRecord *aFromHostRecord);
+ void CopyExpirationTimesAndFlagsFrom(const nsHostRecord *aFromHostRecord);
// Checks if the record is usable (not expired and has a value)
bool HasUsableResult(const mozilla::TimeStamp& now, uint16_t queryFlags = 0) const;
// hold addr_info_lock when calling the blacklist functions
bool Blacklisted(mozilla::net::NetAddr *query);
void ResetBlacklist();
void ReportUnusable(mozilla::net::NetAddr *addr);