Bug 1363659 - Ensure not sending IPC constructor in HTTP channel when shutting down, r=nwgh
authorJunior Hsu <juhsu@mozilla.com>
Fri, 26 May 2017 03:10:00 +0200
changeset 409306 4340666eb8e0d8672aeb69fe9caefae86582f9a9
parent 409305 f5c6864de334fe9a4d362be856adb8682d637b29
child 409307 395b41d878df7f27165c92fca5ad9f33b720ce95
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnwgh
bugs1363659
milestone55.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 1363659 - Ensure not sending IPC constructor in HTTP channel when shutting down, r=nwgh
netwerk/protocol/http/HttpChannelChild.cpp
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -1818,16 +1818,21 @@ HttpChannelChild::ConnectParent(uint32_t
   if (MissingRequiredTabChild(tabChild, "http")) {
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
   if (tabChild && !tabChild->IPCOpen()) {
     return NS_ERROR_FAILURE;
   }
 
+  ContentChild* cc = static_cast<ContentChild*>(gNeckoChild->Manager());
+  if (cc->IsShuttingDown()) {
+    return NS_ERROR_FAILURE;
+  }
+
   HttpBaseChannel::SetDocshellUserAgentOverride();
 
   // The socket transport in the chrome process now holds a logical ref to us
   // until OnStopRequest, or we do a redirect, or we hit an IPDL error.
   AddIPDLReference();
 
   // This must happen before the constructor message is sent. Otherwise messages
   // from the parent could arrive quickly and be delivered to the wrong event
@@ -2660,16 +2665,19 @@ HttpChannelChild::GetAlternativeDataType
 NS_IMETHODIMP
 HttpChannelChild::OpenAlternativeOutputStream(const nsACString & aType, nsIOutputStream * *_retval)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
 
   if (!mIPCOpen) {
     return NS_ERROR_NOT_AVAILABLE;
   }
+  if (static_cast<ContentChild*>(gNeckoChild->Manager())->IsShuttingDown()) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
 
   RefPtr<AltDataOutputStreamChild> stream =
     static_cast<AltDataOutputStreamChild*>(gNeckoChild->SendPAltDataOutputStreamConstructor(nsCString(aType), this));
   stream.forget(_retval);
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
@@ -2991,16 +2999,19 @@ HttpChannelChild::DivertToParent(Channel
 
   // Once this is set, it should not be unset before the child is taken down.
   mDivertingToParent = true;
 
   rv = Suspend();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
+  if (static_cast<ContentChild*>(gNeckoChild->Manager())->IsShuttingDown()) {
+    return NS_ERROR_FAILURE;
+  }
 
   HttpChannelDiverterArgs args;
   args.mChannelChild() = this;
   args.mApplyConversion() = mApplyConversion;
 
   PChannelDiverterChild* diverter =
     gNeckoChild->SendPChannelDiverterConstructor(args);
   MOZ_RELEASE_ASSERT(diverter);