Bug 1515459 - Check if we reenter CreateShimError. r=mayhemer, a=RyanVM
authorDragana Damjanovic <dd.mozilla@gmail.com>
Tue, 08 Jan 2019 20:40:35 +0000
changeset 509426 da0b07a8386c07b7b4c54a5c001fbedc64fa79eb
parent 509425 60be2a80ee0e8c213d16a192780a9f70ac6f5d5a
child 509427 371b3ceabd5ad8568cff2af7255543e2a141d6d2
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer, RyanVM
bugs1515459
milestone65.0
Bug 1515459 - Check if we reenter CreateShimError. r=mayhemer, a=RyanVM 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