Bug 1575780 - We need a long request's timeout for trronly mode. r=mayhemer
authorDragana Damjanovic <dd.mozilla@gmail.com>
Mon, 26 Aug 2019 19:52:20 +0000
changeset 550442 a902d015e909abb13de811988b58490111786cdb
parent 550441 166dc4cccabd9fbd3f4533c24ad18fb7a608f8b5
child 550443 e7511b57c48e74f369ab71162adc6699a2f9ee99
push id11858
push userrmaries@mozilla.com
push dateThu, 29 Aug 2019 15:29:30 +0000
treeherdermozilla-beta@e9268d2f3233 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1575780
milestone70.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 1575780 - We need a long request's timeout for trronly mode. r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D43410
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
netwerk/dns/TRRService.cpp
netwerk/dns/TRRService.h
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -6059,16 +6059,28 @@
   mirror: always
 
 # Whether to run proxy checks when processing Alt-Svc headers.
 - name: network.http.altsvc.proxy_checks
   type: bool
   value: true
   mirror: always
 
+# Single TRR request timeout, in milliseconds
+- name: network.trr.request_timeout_ms
+  type: uint32_t
+  value: 1500
+  mirror: always
+
+# Single TRR request timeout, in milliseconds for mode 3
+- name: network.trr.request_timeout_mode_trronly_ms
+  type: uint32_t
+  value: 30000
+  mirror: always
+
 #---------------------------------------------------------------------------
 # Prefs starting with "nglayout."
 #---------------------------------------------------------------------------
 
 # Enable/disable display list invalidation logging --- useful for debugging.
 - name: nglayout.debug.invalidation
   type: bool
   value: false
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5001,18 +5001,16 @@ pref("network.trr.useGET", false);
 // from the DOH end point to ensure proper configuration
 pref("network.trr.confirmationNS", "example.com");
 // hardcode the resolution of the hostname in network.trr.uri instead of
 // relying on the system resolver to do it for you
 pref("network.trr.bootstrapAddress", "");
 // TRR blacklist entry expire time (in seconds). Default is one minute.
 // Meant to survive basically a page load.
 pref("network.trr.blacklist-duration", 60);
-// Single TRR request timeout, in milliseconds
-pref("network.trr.request-timeout", 1500);
 // Allow AAAA entries to be used "early", before the A results are in
 pref("network.trr.early-AAAA", false);
 // When true, it only sends AAAA when the system has IPv6 connectivity
 pref("network.trr.skip-AAAA-when-not-supported", true);
 // When true, the DNS request will wait for both A and AAAA responses
 // (if both have been requested) before notifying the listeners.
 // When true, it effectively cancels `network.trr.early-AAAA`
 pref("network.trr.wait-for-A-and-AAAA", true);
--- a/netwerk/dns/TRRService.cpp
+++ b/netwerk/dns/TRRService.cpp
@@ -8,16 +8,17 @@
 #include "nsIObserverService.h"
 #include "nsIURIMutator.h"
 #include "nsNetUtil.h"
 #include "nsStandardURL.h"
 #include "TRR.h"
 #include "TRRService.h"
 
 #include "mozilla/Preferences.h"
+#include "mozilla/StaticPrefs_network.h"
 #include "mozilla/Tokenizer.h"
 
 static const char kOpenCaptivePortalLoginEvent[] = "captive-portal-login";
 static const char kClearPrivateData[] = "clear-private-data";
 static const char kPurge[] = "browser:purge-session-history";
 static const char kDisableIpv6Pref[] = "network.dns.disableIPv6";
 static const char kCaptivedetectCanonicalURL[] = "captivedetect.canonicalURL";
 
@@ -34,17 +35,16 @@ extern mozilla::LazyLogModule gHostResol
 TRRService* gTRRService = nullptr;
 
 NS_IMPL_ISUPPORTS(TRRService, nsIObserver, nsISupportsWeakReference)
 
 TRRService::TRRService()
     : mInitialized(false),
       mMode(0),
       mTRRBlacklistExpireTime(72 * 3600),
-      mTRRTimeout(3000),
       mLock("trrservice"),
       mConfirmationNS(NS_LITERAL_CSTRING("example.com")),
       mWaitForCaptive(true),
       mRfc1918(false),
       mCaptiveIsPassed(false),
       mUseGET(false),
       mDisableECS(true),
       mDisableAfterFails(5),
@@ -250,23 +250,16 @@ nsresult TRRService::ReadPrefs(const cha
   if (!name || !strcmp(name, TRR_PREF("blacklist-duration"))) {
     // prefs is given in number of seconds
     uint32_t secs;
     if (NS_SUCCEEDED(
             Preferences::GetUint(TRR_PREF("blacklist-duration"), &secs))) {
       mTRRBlacklistExpireTime = secs;
     }
   }
-  if (!name || !strcmp(name, TRR_PREF("request-timeout"))) {
-    // number of milliseconds
-    uint32_t ms;
-    if (NS_SUCCEEDED(Preferences::GetUint(TRR_PREF("request-timeout"), &ms))) {
-      mTRRTimeout = ms;
-    }
-  }
   if (!name || !strcmp(name, TRR_PREF("early-AAAA"))) {
     bool tmp;
     if (NS_SUCCEEDED(Preferences::GetBool(TRR_PREF("early-AAAA"), &tmp))) {
       mEarlyAAAA = tmp;
     }
   }
 
   if (!name || !strcmp(name, TRR_PREF("skip-AAAA-when-not-supported"))) {
@@ -340,16 +333,24 @@ nsresult TRRService::GetURI(nsCString& r
 }
 
 nsresult TRRService::GetCredentials(nsCString& result) {
   MutexAutoLock lock(mLock);
   result = mPrivateCred;
   return NS_OK;
 }
 
+uint32_t TRRService::GetRequestTimeout() {
+  if (mMode == MODE_TRRONLY) {
+    return StaticPrefs::network_trr_request_timeout_mode_trronly_ms();
+  }
+
+  return StaticPrefs::network_trr_request_timeout_ms();
+}
+
 nsresult TRRService::Start() {
   MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   if (!mInitialized) {
     return NS_ERROR_NOT_INITIALIZED;
   }
   return NS_OK;
 }
 
--- a/netwerk/dns/TRRService.h
+++ b/netwerk/dns/TRRService.h
@@ -37,17 +37,17 @@ class TRRService : public nsIObserver,
   bool UseGET() { return mUseGET; }
   bool EarlyAAAA() { return mEarlyAAAA; }
   bool CheckIPv6Connectivity() { return mCheckIPv6Connectivity; }
   bool WaitForAllResponses() { return mWaitForAllResponses; }
   bool DisableIPv6() { return mDisableIPv6; }
   bool DisableECS() { return mDisableECS; }
   nsresult GetURI(nsCString& result);
   nsresult GetCredentials(nsCString& result);
-  uint32_t GetRequestTimeout() { return mTRRTimeout; }
+  uint32_t GetRequestTimeout();
 
   LookupStatus CompleteLookup(nsHostRecord*, nsresult, mozilla::net::AddrInfo*,
                               bool pb,
                               const nsACString& aOriginSuffix) override;
   LookupStatus CompleteLookupByType(nsHostRecord*, nsresult,
                                     const nsTArray<nsCString>*, uint32_t,
                                     bool pb) override;
   void TRRBlacklist(const nsACString& host, const nsACString& originSuffix,
@@ -69,17 +69,16 @@ class TRRService : public nsIObserver,
   void MaybeConfirm();
   void MaybeConfirm_locked();
   friend class ::nsDNSService;
   void GetParentalControlEnabledInternal();
 
   bool mInitialized;
   Atomic<uint32_t, Relaxed> mMode;
   Atomic<uint32_t, Relaxed> mTRRBlacklistExpireTime;
-  Atomic<uint32_t, Relaxed> mTRRTimeout;
 
   Mutex mLock;
 
   nsCString mPrivateURI;   // main thread only
   nsCString mPrivateCred;  // main thread only
   nsCString mConfirmationNS;
   nsCString mBootstrapAddr;