Bug 1475420 - mark the TRR connection as DISABLE_TRR to avoid TXT deadlock r=bagder draft
authorPatrick McManus <mcmanus@ducksong.com>
Thu, 12 Jul 2018 17:48:54 -0400
changeset 817588 f23e29f34970cebd3bc741bf686d66f2c3cf5784
parent 814904 fa376bf17cc95539f5e37186977d760296fb5093
push id116123
push userbmo:mcmanus@ducksong.com
push dateFri, 13 Jul 2018 00:44:35 +0000
reviewersbagder
bugs1475420
milestone63.0a1
Bug 1475420 - mark the TRR connection as DISABLE_TRR to avoid TXT deadlock r=bagder MozReview-Commit-ID: 3xF3Hb5rpyh
netwerk/protocol/http/nsHttp.h
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpConnectionMgr.cpp
--- a/netwerk/protocol/http/nsHttp.h
+++ b/netwerk/protocol/http/nsHttp.h
@@ -102,16 +102,20 @@ namespace net {
 
 // Transactions with this flag should be processed first.
 #define NS_HTTP_URGENT_START         (1<<12)
 
 // A sticky connection of the transaction is explicitly allowed to be restarted
 // on ERROR_NET_RESET.
 #define NS_HTTP_CONNECTION_RESTARTABLE  (1<<13)
 
+// Disallow name resolutions for this transaction to use TRR - primarily
+// for use with TRR implementations themselves
+#define NS_HTTP_DISABLE_TRR (1<<14)
+
 //-----------------------------------------------------------------------------
 // some default values
 //-----------------------------------------------------------------------------
 
 #define NS_HTTP_DEFAULT_PORT  80
 #define NS_HTTPS_DEFAULT_PORT 443
 
 #define NS_HTTP_HEADER_SEPS ", \t"
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -496,16 +496,20 @@ nsHttpChannel::OnBeforeConnect()
     // ensure that we are using a valid hostname
     if (!net_IsValidHostName(nsDependentCString(mConnectionInfo->Origin())))
         return NS_ERROR_UNKNOWN_HOST;
 
     if (mUpgradeProtocolCallback) {
         mCaps |=  NS_HTTP_DISALLOW_SPDY;
     }
 
+    if (mTRR) {
+        mCaps |= NS_HTTP_LARGE_KEEPALIVE | NS_HTTP_DISABLE_TRR;
+    }
+
     // Finalize ConnectionInfo flags before SpeculativeConnect
     mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
     mConnectionInfo->SetPrivate(mPrivateBrowsing);
     mConnectionInfo->SetNoSpdy(mCaps & NS_HTTP_DISALLOW_SPDY);
     mConnectionInfo->SetBeConservative((mCaps & NS_HTTP_BE_CONSERVATIVE) || mBeConservative);
     mConnectionInfo->SetTlsFlags(mTlsFlags);
 
     // notify "http-on-before-connect" observers
@@ -753,17 +757,18 @@ nsHttpChannel::SpeculativeConnect()
 
     nsCOMPtr<nsIInterfaceRequestor> callbacks;
     NS_NewNotificationCallbacksAggregation(mCallbacks, mLoadGroup,
                                            getter_AddRefs(callbacks));
     if (!callbacks)
         return;
 
     Unused << gHttpHandler->SpeculativeConnect(
-        mConnectionInfo, callbacks, mCaps & NS_HTTP_DISALLOW_SPDY);
+        mConnectionInfo, callbacks,
+        mCaps & (NS_HTTP_DISALLOW_SPDY | NS_HTTP_DISABLE_TRR));
 }
 
 void
 nsHttpChannel::DoNotifyListenerCleanup()
 {
     // We don't need this info anymore
     CleanRedirectCacheChainIfNecessary();
 }
@@ -968,19 +973,16 @@ nsHttpChannel::SetupTransaction()
                 mAltDataLength = 0;
             }
             mCacheInputStream.CloseAndRelease();
         }
     }
 
     mUsedNetwork = 1;
 
-    if (mTRR) {
-        mCaps |= NS_HTTP_LARGE_KEEPALIVE;
-    }
     if (!mAllowSpdy) {
         mCaps |= NS_HTTP_DISALLOW_SPDY;
     }
     if (mBeConservative) {
         mCaps |= NS_HTTP_BE_CONSERVATIVE;
     }
 
     // Use the URI path if not proxying (transparent proxying such as proxy
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -4061,16 +4061,20 @@ nsHalfOpenSocket::SetupStreams(nsISocket
                                   getter_AddRefs(socketTransport));
     }
     NS_ENSURE_SUCCESS(rv, rv);
 
     uint32_t tmpFlags = 0;
     if (mCaps & NS_HTTP_REFRESH_DNS)
         tmpFlags = nsISocketTransport::BYPASS_CACHE;
 
+    if (mCaps & NS_HTTP_DISABLE_TRR) {
+        tmpFlags = nsISocketTransport::DISABLE_TRR;
+    }
+
     if (mCaps & NS_HTTP_LOAD_ANONYMOUS)
         tmpFlags |= nsISocketTransport::ANONYMOUS_CONNECT;
 
     if (ci->GetPrivate())
         tmpFlags |= nsISocketTransport::NO_PERMANENT_STORAGE;
 
     if ((mCaps & NS_HTTP_BE_CONSERVATIVE) || ci->GetBeConservative()) {
         LOG(("Setting Socket to BE_CONSERVATIVE"));