bug 1463356 do not count "not started" TRR resolves as failures r=mcmanus

... when comparing against the native resolver. DNS_TRR_COMPARE is meant
to compare how the actually performed name resolves fare against each
other.

MozReview-Commit-ID: 98NoUGPpHr6

--HG--
extra : rebase_source : 4042c81da3e5478de26feb7f83c98ee5eb298156
This commit is contained in:
Daniel Stenberg 2018-06-20 11:00:19 +02:00
Родитель 67eb7f4c9f
Коммит 7e7f7eeb34
4 изменённых файлов: 27 добавлений и 6 удалений

Просмотреть файл

@ -122,7 +122,7 @@ TRR::Run()
{
MOZ_ASSERT(NS_IsMainThread());
if ((gTRRService == nullptr) || NS_FAILED(SendHTTPRequest())) {
FailData();
FailData(NS_ERROR_FAILURE);
// The dtor will now be run
}
return NS_OK;
@ -850,7 +850,7 @@ TRR::ReturnData()
}
nsresult
TRR::FailData()
TRR::FailData(nsresult error)
{
if (!mHostResolver) {
return NS_ERROR_FAILURE;
@ -859,7 +859,7 @@ TRR::FailData()
// this comes from TRR
AddrInfo *ai = new AddrInfo(mHost, mType);
(void)mHostResolver->CompleteLookup(mRec, NS_ERROR_FAILURE, ai, mPB);
(void)mHostResolver->CompleteLookup(mRec, error, ai, mPB);
mHostResolver = nullptr;
mRec = nullptr;
return NS_OK;
@ -933,7 +933,7 @@ TRR::OnStopRequest(nsIRequest *aRequest,
// try and parse missing content-types, but otherwise require udpwireformat
LOG(("TRR:OnStopRequest %p %s %d should fail due to content type %s\n",
this, mHost.get(), mType, contentType.get()));
FailData();
FailData(NS_ERROR_UNEXPECTED);
return NS_OK;
}
@ -952,7 +952,7 @@ TRR::OnStopRequest(nsIRequest *aRequest,
LOG(("TRR:OnStopRequest %p status %x mFailed %d\n",
this, (int)aStatusCode, mFailed));
FailData();
FailData(NS_ERROR_UNKNOWN_HOST);
return NS_OK;
}

Просмотреть файл

@ -147,7 +147,14 @@ private:
nsresult GetQname(nsAutoCString &aQname, unsigned int &aIndex);
nsresult DohDecode(nsCString &aHost);
nsresult ReturnData();
nsresult FailData();
// FailData() must be called to signal that the asynch TRR resolve is
// completed. For failed name resolves ("no such host"), the 'error' it
// passses on in its argument must be NS_ERROR_UNKNOWN_HOST. Other errors
// (if host was blacklisted, there as a bad content-type received, etc)
// other error codes must be used. This distinction is important for the
// subsequent logic to separate the error reasons.
nsresult FailData(nsresult error);
nsresult DohDecodeQuery(const nsCString &query,
nsCString &host, enum TrrType &type);
nsresult ReceivePush(nsIHttpChannel *pushed, nsHostRecord *pushedRec);

Просмотреть файл

@ -184,6 +184,7 @@ nsHostRecord::nsHostRecord(const nsHostKey& key)
, addr(nullptr)
, negative(false)
, mResolverMode(MODE_NATIVEONLY)
, mFirstTRRresult(NS_OK)
, mResolving(0)
, mTRRSuccess(0)
, mNativeSuccess(0)
@ -1519,6 +1520,7 @@ nsHostResolver::CompleteLookup(nsHostRecord* rec, nsresult status, AddrInfo* aNe
rec->mTRRSuccess++;
}
if (TRROutstanding()) {
rec->mFirstTRRresult = status;
if (NS_FAILED(status)) {
return LOOKUP_OK; // wait for outstanding
}
@ -1558,6 +1560,16 @@ nsHostResolver::CompleteLookup(nsHostRecord* rec, nsresult status, AddrInfo* aNe
rec->mFirstTRR = nullptr;
}
if (NS_FAILED(rec->mFirstTRRresult) &&
NS_FAILED(status) &&
(rec->mFirstTRRresult != NS_ERROR_UNKNOWN_HOST) &&
(status != NS_ERROR_UNKNOWN_HOST)) {
// the errors are not failed resolves, that means
// something else failed, consider this as *TRR not used*
// for actually trying to resolve the host
rec->mTRRUsed = false;
}
if (!rec->mTRRSuccess) {
// no TRR success
newRRSet = nullptr;
@ -1570,6 +1582,7 @@ nsHostResolver::CompleteLookup(nsHostRecord* rec, nsresult status, AddrInfo* aNe
MOZ_ASSERT(rec->mResolving);
return LOOKUP_OK;
}
// continue
}

Просмотреть файл

@ -174,6 +174,7 @@ private:
explicit nsHostRecord(const nsHostKey& key);
mozilla::LinkedList<RefPtr<nsResolveHostCallback>> mCallbacks;
nsAutoPtr<mozilla::net::AddrInfo> mFirstTRR; // partial TRR storage
nsresult mFirstTRRresult;
uint16_t mResolving; // counter of outstanding resolving calls
uint8_t mTRRSuccess; // number of successful TRR responses