bug 1455972 - make TRR prefer address responses to CNAME r?mcmanus
In a DOH response to a query asking for an A or AAAA record, a CNAME
response is often accompanied by A/AAAA resources as well. With this
change, TRR now rather use those address records than following the
CNAME record. This saves name resolver round-trips.
MozReview-Commit-ID: GcjZj5Ehz68
--- a/netwerk/dns/TRR.cpp
+++ b/netwerk/dns/TRR.cpp
@@ -814,17 +814,17 @@ TRR::FailData()
nsresult
TRR::On200Response()
{
// decode body and create an AddrInfo struct for the response
nsresult rv = DohDecode();
if (NS_SUCCEEDED(rv)) {
- if (!mCname.IsEmpty()) {
+ if (!mDNS.mAddresses.getFirst() && !mCname.IsEmpty()) {
if (!--mCnameLoop) {
LOG(("TRR::On200Response CNAME loop, eject!\n"));
} else {
LOG(("TRR::On200Response CNAME %s => %s (%u)\n", mHost.get(), mCname.get(),
mCnameLoop));
RefPtr<TRR> trr = new TRR(mHostResolver, mRec, mCname,
mType, mCnameLoop, mPB);
rv = NS_DispatchToMainThread(trr);