bug 1470093 - fix telemetry::DNS_TRR_LOOKUP_TIME r?mcmanus draft
authorDaniel Stenberg <daniel@haxx.se>
Thu, 21 Jun 2018 12:02:03 +0200
changeset 809155 b41c6dc5ad624e77a37965d178ad02c61834593b
parent 809154 e834d23a292972ab4250a8be00e6740c43e41db2
push id113554
push userbmo:daniel@haxx.se
push dateThu, 21 Jun 2018 10:18:22 +0000
reviewersmcmanus
bugs1470093
milestone62.0a1
bug 1470093 - fix telemetry::DNS_TRR_LOOKUP_TIME r?mcmanus MozReview-Commit-ID: 80jrEQ4kLM6
netwerk/dns/nsHostResolver.cpp
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -1513,16 +1513,23 @@ nsHostResolver::CompleteLookup(nsHostRec
             rec->mTrrAAAA = nullptr;
             rec->mTrrAAAAUsed = NS_SUCCEEDED(status) ? nsHostRecord::OK : nsHostRecord::FAILED;
         } else {
             MOZ_ASSERT(0);
         }
 
         if (NS_SUCCEEDED(status)) {
             rec->mTRRSuccess++;
+            if (rec->mTRRSuccess == 1) {
+                // Store the duration on first succesful TRR response.  We
+                // don't know that there will be a second response nor can we
+                // tell which of two has useful data, especially in
+                // MODE_SHADOW where the actual results are discarded.
+                rec->mTrrDuration = TimeStamp::Now() - rec->mTrrStart;
+            }
         }
         if (TRROutstanding()) {
             rec->mFirstTRRresult = status;
             if (NS_FAILED(status)) {
                 return LOOKUP_OK; // wait for outstanding
             }
 
             // There's another TRR complete pending. Wait for it and keep
@@ -1581,21 +1588,16 @@ nsHostResolver::CompleteLookup(nsHostRec
                 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;