Bug 1364189 - Make sure not to retry socketTransaction if nsHttpConnectionMgr cancels it. r=mcmanus, a=gchang
authorDragana Damjanovic <dd.mozilla@gmail.com>
Mon, 15 May 2017 06:20:00 -0400
changeset 394017 f43af7eb586c95d0473e98635470dca344604905
parent 394016 0a1b96abe72e99729e992daf3babf0d05262a910
child 394018 e609219b9f585e3400d1c7a4f6947e6b74554766
push id7331
push userryanvm@gmail.com
push dateFri, 19 May 2017 17:36:20 +0000
treeherdermozilla-beta@72da880beaeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, gchang
bugs1364189
milestone54.0
Bug 1364189 - Make sure not to retry socketTransaction if nsHttpConnectionMgr cancels it. r=mcmanus, a=gchang
netwerk/base/nsSocketTransport2.cpp
netwerk/base/nsSocketTransport2.h
--- a/netwerk/base/nsSocketTransport2.cpp
+++ b/netwerk/base/nsSocketTransport2.cpp
@@ -761,16 +761,17 @@ nsSocketTransport::nsSocketTransport()
     , mSocketTransportService(gSocketTransportService)
     , mInput(this)
     , mOutput(this)
     , mQoSBits(0x00)
     , mKeepaliveEnabled(false)
     , mKeepaliveIdleTimeS(-1)
     , mKeepaliveRetryIntervalS(-1)
     , mKeepaliveProbeCount(-1)
+    , mDoNotRetryToConnect(false)
 {
     SOCKET_LOG(("creating nsSocketTransport @%p\n", this));
 
     mTimeouts[TIMEOUT_CONNECT]    = UINT16_MAX; // no timeout
     mTimeouts[TIMEOUT_READ_WRITE] = UINT16_MAX; // no timeout
 }
 
 nsSocketTransport::~nsSocketTransport()
@@ -1586,16 +1587,23 @@ nsSocketTransport::InitiateSocket()
 bool
 nsSocketTransport::RecoverFromError()
 {
     NS_ASSERTION(NS_FAILED(mCondition), "there should be something wrong");
 
     SOCKET_LOG(("nsSocketTransport::RecoverFromError [this=%p state=%x cond=%" PRIx32 "]\n",
                 this, mState, static_cast<uint32_t>(mCondition)));
 
+    if (mDoNotRetryToConnect) {
+        SOCKET_LOG(("nsSocketTransport::RecoverFromError do not retry because "
+                    "mDoNotRetryToConnect is set [this=%p]\n",
+                    this));
+        return false;
+    }
+
 #if defined(XP_UNIX)
     // Unix domain connections don't have multiple addresses to try,
     // so the recovery techniques here don't apply.
     if (mNetAddrIsSet && mNetAddr.raw.family == AF_LOCAL)
         return false;
 #endif
 
     // can only recover from errors in these states
@@ -2295,16 +2303,18 @@ nsSocketTransport::OpenOutputStream(uint
 }
 
 NS_IMETHODIMP
 nsSocketTransport::Close(nsresult reason)
 {
     if (NS_SUCCEEDED(reason))
         reason = NS_BASE_STREAM_CLOSED;
 
+    mDoNotRetryToConnect = true;
+
     mInput.CloseWithStatus(reason);
     mOutput.CloseWithStatus(reason);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSocketTransport::GetSecurityInfo(nsISupports **secinfo)
 {
--- a/netwerk/base/nsSocketTransport2.h
+++ b/netwerk/base/nsSocketTransport2.h
@@ -457,14 +457,16 @@ private:
     // True if keepalive has been enabled by the socket owner. Note: Keepalive
     // must also be enabled globally for it to be enabled in TCP.
     bool mKeepaliveEnabled;
 
     // Keepalive config (support varies by platform).
     int32_t mKeepaliveIdleTimeS;
     int32_t mKeepaliveRetryIntervalS;
     int32_t mKeepaliveProbeCount;
+
+    bool mDoNotRetryToConnect;
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif // !nsSocketTransport_h__