Bug 1515459 - Check if we reenter CreateShimError. r=mayhemer
authorDragana Damjanovic <dd.mozilla@gmail.com>
Tue, 08 Jan 2019 20:40:35 +0000
changeset 510298 740f1995b1281671ca4fe49ad97d834a19d29016
parent 510297 5665c5f251985c3f2e54a5bb0f18db99a58b8acd
child 510299 4e943c6de64e19c107902ca41e5d18a6ec9d1395
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1515459
milestone66.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 1515459 - Check if we reenter CreateShimError. r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D15297
netwerk/protocol/http/TunnelUtils.cpp
netwerk/protocol/http/TunnelUtils.h
--- a/netwerk/protocol/http/TunnelUtils.cpp
+++ b/netwerk/protocol/http/TunnelUtils.cpp
@@ -989,17 +989,18 @@ SpdyConnectTransaction::SpdyConnectTrans
       mInputDataSize(0),
       mInputDataUsed(0),
       mInputDataOffset(0),
       mOutputDataSize(0),
       mOutputDataUsed(0),
       mOutputDataOffset(0),
       mForcePlainText(false),
       mIsWebsocket(isWebsocket),
-      mConnRefTaken(false) {
+      mConnRefTaken(false),
+      mCreateShimErrorCalled(false) {
   LOG(("SpdyConnectTransaction ctor %p\n", this));
 
   mTimestampSyn = TimeStamp::Now();
   mRequestHead = new nsHttpRequestHead();
   if (mIsWebsocket) {
     // Ensure our request head has all the websocket headers duplicated from the
     // original transaction before calling the boilerplate stuff to create the
     // rest of the CONNECT headers.
@@ -1197,16 +1198,22 @@ nsresult SpdyConnectTransaction::ReadSeg
 
   return rv;
 }
 
 void SpdyConnectTransaction::CreateShimError(nsresult code) {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
   MOZ_ASSERT(NS_FAILED(code));
 
+  MOZ_ASSERT(!mCreateShimErrorCalled);
+  if (mCreateShimErrorCalled) {
+    return;
+  }
+  mCreateShimErrorCalled = true;
+
   if (mTunnelStreamOut && NS_SUCCEEDED(mTunnelStreamOut->mStatus)) {
     mTunnelStreamOut->mStatus = code;
   }
 
   if (mTunnelStreamIn && NS_SUCCEEDED(mTunnelStreamIn->mStatus)) {
     mTunnelStreamIn->mStatus = code;
   }
 
@@ -1218,16 +1225,17 @@ void SpdyConnectTransaction::CreateShimE
   }
 
   if (mTunnelStreamOut) {
     nsIOutputStreamCallback *cb = mTunnelStreamOut->GetCallback();
     if (cb) {
       cb->OnOutputStreamReady(mTunnelStreamOut);
     }
   }
+  mCreateShimErrorCalled = false;
 }
 
 nsresult SpdyConnectTransaction::WriteDataToBuffer(nsAHttpSegmentWriter *writer,
                                                    uint32_t count,
                                                    uint32_t *countWritten) {
   EnsureBuffer(mInputData, mInputDataUsed + count, mInputDataUsed,
                mInputDataSize);
   nsresult rv =
--- a/netwerk/protocol/http/TunnelUtils.h
+++ b/netwerk/protocol/http/TunnelUtils.h
@@ -267,14 +267,16 @@ class SpdyConnectTransaction final : pub
   bool mConnRefTaken;
   nsCOMPtr<nsIAsyncOutputStream> mInputShimPipe;
   nsCOMPtr<nsIAsyncInputStream> mOutputShimPipe;
   nsresult WriteDataToBuffer(nsAHttpSegmentWriter *writer, uint32_t count,
                              uint32_t *countWritten);
   MOZ_MUST_USE nsresult WebsocketWriteSegments(nsAHttpSegmentWriter *writer,
                                                uint32_t count,
                                                uint32_t *countWritten);
+
+  bool mCreateShimErrorCalled;
 };
 
 }  // namespace net
 }  // namespace mozilla
 
 #endif  // mozilla_net_TLSFilterTransaction_h