bug 1439302 - repair the *RESOLVEAGAIN logic in nsHostResolver::CompleteLookup r?valentin
When the native resolve needs to run again, the rec->mResolving counter
must not be decreased, as otherwise it triggers an assert when the next
resolve completes.
MozReview-Commit-ID: 3UQGkDSOmGi
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -1487,24 +1487,30 @@ nsHostResolver::CompleteLookup(nsHostRec
MutexAutoLock lock(mLock);
MOZ_ASSERT(rec);
MOZ_ASSERT(rec->pb == pb);
// newRRSet needs to be taken into the hostrecord (which will then own it)
// or deleted on early return.
nsAutoPtr<AddrInfo> newRRSet(aNewRRSet);
+ bool trrResult = newRRSet && newRRSet->IsTRR();
+
+ if (rec->mResolveAgain && (status != NS_ERROR_ABORT) && !trrResult) {
+ LOG(("nsHostResolver record %p resolve again due to flushcache\n", rec));
+ rec->mResolveAgain = false;
+ return LOOKUP_RESOLVEAGAIN;
+ }
+
MOZ_ASSERT(rec->mResolving);
rec->mResolving--;
LOG(("nsHostResolver::CompleteLookup %s %p %X trr=%d stillResolving=%d\n",
rec->host.get(), aNewRRSet, (unsigned int)status,
aNewRRSet ? aNewRRSet->IsTRR() : 0, rec->mResolving));
- bool trrResult = newRRSet && newRRSet->IsTRR();
-
if (trrResult) {
LOG(("TRR lookup Complete (%d) %s %s\n",
newRRSet->IsTRR(), newRRSet->mHostName,
NS_SUCCEEDED(status) ? "OK" : "FAILED"));
MOZ_ASSERT(TRROutstanding());
if (newRRSet->IsTRR() == TRRTYPE_A) {
MOZ_ASSERT(rec->mTrrA);
rec->mTrrA = nullptr;
@@ -1578,22 +1584,16 @@ nsHostResolver::CompleteLookup(nsHostRec
rec->mNative = false;
rec->mNativeSuccess = newRRSet ? true : false;
if (rec->mNativeSuccess) {
rec->mNativeDuration = TimeStamp::Now() - rec->mNativeStart;
}
}
- if (rec->mResolveAgain && (status != NS_ERROR_ABORT)) {
- LOG(("nsHostResolver record %p resolve again due to flushcache\n", rec));
- rec->mResolveAgain = false;
- return LOOKUP_RESOLVEAGAIN;
- }
-
// update record fields. We might have a rec->addr_info already if a
// previous lookup result expired and we're reresolving it or we get
// a late second TRR response.
// note that we don't update the addr_info if this is trr shadow results
if (!mShutdown &&
!(trrResult && rec->mResolverMode == MODE_SHADOW)) {
MutexAutoLock lock(rec->addr_info_lock);
nsAutoPtr<AddrInfo> old_addr_info;