Bug 1452436 - Callback when resolving a host already in progress. r=mcmanus, a=RyanVM
authorDaniel Stenberg <daniel@haxx.se>
Thu, 10 May 2018 05:36:00 -0400
changeset 470763 1da8d36ce5a4c6f41863ecd4edd5b0ae5c548c69
parent 470762 720baaffac8cf0b71e351720bc3617a508d039d1
child 470764 7b8ada24da4ddc1a1b3961f9d0fffa7fd75f95c3
push id9218
push userryanvm@gmail.com
push dateSun, 13 May 2018 19:56:21 +0000
treeherdermozilla-beta@5fcefe47c777 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, RyanVM
bugs1452436
milestone61.0
Bug 1452436 - Callback when resolving a host already in progress. r=mcmanus, a=RyanVM 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);