bug 1445183 store TRR duration when the response is used r?valentin draft
authorDaniel Stenberg <daniel@haxx.se>
Tue, 13 Mar 2018 10:37:50 +0100
changeset 766834 01cf0beb37090dd2eebd94dbe251b5af02e1f82f
parent 766597 6ff60a083701d08c52702daf50f28e8f46ae3a1c
push id102405
push userbmo:daniel@haxx.se
push dateTue, 13 Mar 2018 11:45:38 +0000
reviewersvalentin
bugs1445183
milestone61.0a1
bug 1445183 store TRR duration when the response is used r?valentin Previously it would store the time even for early AAAA responses that weren't used until the A response came in, thus getting the timing wrong. MozReview-Commit-ID: KctUjMjH5FR
netwerk/dns/nsHostResolver.cpp
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -1512,22 +1512,18 @@ nsHostResolver::CompleteLookup(nsHostRec
             MOZ_ASSERT(rec->mTrrAAAA);
             rec->mTrrAAAA = nullptr;
             rec->mTrrAAAAUsed = NS_SUCCEEDED(status) ? nsHostRecord::OK : nsHostRecord::FAILED;
         } else {
             MOZ_ASSERT(0);
         }
 
         if (NS_SUCCEEDED(status)) {
-            if (rec->mTRRSuccess == 0) { // first one
-                rec->mTrrDuration = TimeStamp::Now() - rec->mTrrStart;
-            }
             rec->mTRRSuccess++;
         }
-
         if (TRROutstanding()) {
             if (NS_FAILED(status)) {
                 return LOOKUP_OK; // wait for outstanding
             }
 
             // There's another TRR complete pending. Wait for it and keep
             // this RRset around until then.
             MOZ_ASSERT(!rec->mFirstTRR && newRRSet);
@@ -1571,16 +1567,22 @@ nsHostResolver::CompleteLookup(nsHostRec
             if (!rec->mTRRSuccess && rec->mResolverMode == MODE_TRRFIRST) {
                 MOZ_ASSERT(!rec->mResolving);
                 NativeLookup(rec);
                 MOZ_ASSERT(rec->mResolving);
                 return LOOKUP_OK;
             }
             // continue
         }
+
+        if (NS_SUCCEEDED(status) && (rec->mTRRSuccess == 1)) {
+            // store the duration on first (used) TRR response
+            rec->mTrrDuration = TimeStamp::Now() - rec->mTrrStart;
+        }
+
     } else { // native resolve completed
         if (rec->usingAnyThread) {
             mActiveAnyThreadCount--;
             rec->usingAnyThread = false;
         }
 
         rec->mNative = false;
         rec->mNativeSuccess = newRRSet ? true : false;