Bug 1452436 - Callback when resolving a host already in progress. r=mcmanus
authorDaniel Stenberg <daniel@haxx.se>
Thu, 10 May 2018 05:36:00 -0400
changeset 417757 9d23e0279ecde11c1ffefd82e1d1f8c4d3d8adb8
parent 417756 70754a946fde161c04f86df1b67e3913c8ec590a
child 417758 ce7a39303eff573c740268bcb9dacd013c9c02f4
push id33979
push userdluca@mozilla.com
push dateThu, 10 May 2018 21:59:38 +0000
treeherdermozilla-central@aabfe960ab59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1452436
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1452436 - Callback when resolving a host already in progress. r=mcmanus If a callback has already been called for the hostrecord, it is partially resolved already by TRR so the new callback should be called at once.
netwerk/dns/nsHostResolver.cpp
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -945,16 +945,24 @@ nsHostResolver::ResolveHost(const char  
                     if (NS_FAILED(rv) && callback->isInList()) {
                         callback->remove();
                     } else {
                         LOG(("  DNS lookup for host [%s%s%s] blocking "
                              "pending 'getaddrinfo' query: callback [%p]",
                              LOG_HOST(host, netInterface), callback.get()));
                     }
                 }
+            } else if (rec->mDidCallbacks) {
+                // record is still pending more (TRR) data; make the callback
+                // at once
+                result = rec;
+                // make it count as a hit
+                Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2, METHOD_HIT);
+                LOG(("  Host [%s%s%s] re-using early TRR resolve data\n",
+                     LOG_HOST(host, netInterface)));
             } else {
                 LOG(("  Host [%s%s%s] is being resolved. Appending callback "
                      "[%p].", LOG_HOST(host, netInterface), callback.get()));
 
                 rec->mCallbacks.insertBack(callback);
                 if (rec->onQueue) {
                     Telemetry::Accumulate(Telemetry::DNS_LOOKUP_METHOD2,
                                           METHOD_NETWORK_SHARED);