зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1123324 - Additional fix for nsHostResolver. r=sworkman
This commit is contained in:
Родитель
4dc62c20e6
Коммит
bcda688027
|
@ -210,11 +210,14 @@ nsHostRecord::SetExpiration(const mozilla::TimeStamp& now, unsigned int valid, u
|
|||
}
|
||||
|
||||
void
|
||||
nsHostRecord::CopyExpirationTimesFrom(const nsHostRecord *aFromHostRecord)
|
||||
nsHostRecord::CopyExpirationTimesAndFlagsFrom(const nsHostRecord *aFromHostRecord)
|
||||
{
|
||||
// This is used to copy information from a cache entry to a record. All
|
||||
// information necessary for HasUsableRecord needs to be copied.
|
||||
mValidStart = aFromHostRecord->mValidStart;
|
||||
mValidEnd = aFromHostRecord->mValidEnd;
|
||||
mGraceStart = aFromHostRecord->mGraceStart;
|
||||
mDoomed = aFromHostRecord->mDoomed;
|
||||
}
|
||||
|
||||
nsHostRecord::~nsHostRecord()
|
||||
|
@ -839,8 +842,9 @@ nsHostResolver::ResolveHost(const char *host,
|
|||
NS_ASSERTION(!unspecHe ||
|
||||
(unspecHe && unspecHe->rec),
|
||||
"Valid host entries should contain a record");
|
||||
TimeStamp now = TimeStamp::NowLoRes();
|
||||
if (unspecHe &&
|
||||
unspecHe->rec->HasUsableResult(TimeStamp::NowLoRes(), flags)) {
|
||||
unspecHe->rec->HasUsableResult(now, flags)) {
|
||||
|
||||
MOZ_ASSERT(unspecHe->rec->addr_info || unspecHe->rec->negative,
|
||||
"Entry should be resolved or negative.");
|
||||
|
@ -851,7 +855,7 @@ nsHostResolver::ResolveHost(const char *host,
|
|||
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
|
||||
|
@ -865,7 +869,7 @@ nsHostResolver::ResolveHost(const char *host,
|
|||
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));
|
||||
|
@ -873,8 +877,12 @@ nsHostResolver::ResolveHost(const char *host,
|
|||
addrIter = addrIter->getNext();
|
||||
}
|
||||
}
|
||||
if (he->rec->HasUsableResult(TimeStamp::NowLoRes(), flags)) {
|
||||
// Now check if we have a new record.
|
||||
if (he->rec->HasUsableResult(now, flags)) {
|
||||
result = he->rec;
|
||||
if (he->rec->negative) {
|
||||
status = NS_ERROR_UNKNOWN_HOST;
|
||||
}
|
||||
Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
|
||||
METHOD_HIT);
|
||||
ConditionallyRefreshRecord(he->rec, host);
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
// 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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче