bug 1485956 - make DNS cache lookups respect DISABLE_TRR r=valentin
authorDaniel Stenberg <daniel@haxx.se>
Fri, 24 Aug 2018 14:09:22 +0000
changeset 433290 9f1b27308bd6dfaa17c75720660b5bf40cd4ccab
parent 433289 1dc785e713d98436719d12616ececf74d0b34bcc
child 433291 bb0042103f68788758de50417a7b3cf4c21a88b6
push id34503
push useraiakab@mozilla.com
push dateFri, 24 Aug 2018 22:07:45 +0000
treeherdermozilla-central@d2da77c319d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1485956
milestone63.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 1485956 - make DNS cache lookups respect DISABLE_TRR r=valentin So that explicitly disabling TRR for specific resolves won't end up just using the cached entry resolved with TRR! MozReview-Commit-ID: HZ4AyKOMpet Differential Revision: https://phabricator.services.mozilla.com/D4215
netwerk/dns/nsHostResolver.cpp
netwerk/dns/nsHostResolver.h
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -147,17 +147,32 @@ IsLowPriority(uint16_t flags)
 {
     return flags & nsHostResolver::RES_PRIORITY_LOW;
 }
 
 //----------------------------------------------------------------------------
 // this macro filters out any flags that are not used when constructing the
 // host key.  the significant flags are those that would affect the resulting
 // host record (i.e., the flags that are passed down to PR_GetAddrInfoByName).
-#define RES_KEY_FLAGS(_f) ((_f) & nsHostResolver::RES_CANON_NAME)
+#define RES_KEY_FLAGS(_f) ((_f) & (nsHostResolver::RES_CANON_NAME |     \
+                                   nsHostResolver::RES_DISABLE_TRR))
+
+nsHostKey::nsHostKey(const nsACString& aHost, uint16_t aFlags,
+                     uint16_t aAf, bool aPb, const nsACString& aOriginsuffix)
+  : host(aHost)
+  , flags(aFlags)
+  , af(aAf)
+  , pb(aPb)
+  , originSuffix(aOriginsuffix)
+{
+  if (TRR_DISABLED(gTRRService->Mode())) {
+    // When not using TRR, lookup all answers as TRR-disabled
+    flags |= nsHostResolver::RES_DISABLE_TRR;
+  }
+}
 
 bool
 nsHostKey::operator==(const nsHostKey& other) const
 {
     return host == other.host &&
         RES_KEY_FLAGS (flags) == RES_KEY_FLAGS(other.flags) &&
         af == other.af &&
         originSuffix == other.originSuffix;
--- a/netwerk/dns/nsHostResolver.h
+++ b/netwerk/dns/nsHostResolver.h
@@ -52,26 +52,18 @@ extern mozilla::Atomic<bool, mozilla::Re
 
 struct nsHostKey
 {
     const nsCString host;
     uint16_t flags;
     uint16_t af;
     bool     pb;
     const nsCString originSuffix;
-
-    nsHostKey(const nsACString& host, uint16_t flags,
-              uint16_t af, bool pb, const nsACString& originSuffix)
-        : host(host)
-        , flags(flags)
-        , af(af)
-        , pb(pb)
-        , originSuffix(originSuffix) {
-    }
-
+    explicit nsHostKey(const nsACString& host, uint16_t flags,
+                       uint16_t af, bool pb, const nsACString& originSuffix);
     bool operator==(const nsHostKey& other) const;
     size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
     PLDHashNumber Hash() const;
 };
 
 /**
  * nsHostRecord - ref counted object type stored in host resolver cache.
  */