Bug 1363659 - Ensure not sending IPC constructor in FTP channel when shutting down, r=valentin
authorJunior Hsu <juhsu@mozilla.com>
Fri, 26 May 2017 03:09:00 +0200
changeset 361187 dcbaf5f542b6c45312a72621e539ca79e10fc2b5
parent 361186 8806b294e566770ebbf73daee9dfe8f69b67885e
child 361188 f5c6864de334fe9a4d362be856adb8682d637b29
push id31918
push usercbook@mozilla.com
push dateTue, 30 May 2017 09:39:11 +0000
treeherdermozilla-central@286f71223256 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
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 FTP channel when shutting down, r=valentin
netwerk/protocol/ftp/FTPChannelChild.cpp
--- a/netwerk/protocol/ftp/FTPChannelChild.cpp
+++ b/netwerk/protocol/ftp/FTPChannelChild.cpp
@@ -19,16 +19,17 @@
 #include "nsNetUtil.h"
 #include "base/compiler_specific.h"
 #include "mozilla/ipc/IPCStreamUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "SerializedLoadContext.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "nsIPrompt.h"
 
+using mozilla::dom::ContentChild;
 using namespace mozilla::ipc;
 
 #undef LOG
 #define LOG(args) MOZ_LOG(gFTPLog, mozilla::LogLevel::Debug, args)
 
 namespace mozilla {
 namespace net {
 
@@ -148,16 +149,18 @@ FTPChannelChild::GetUploadStream(nsIInpu
 }
 
 NS_IMETHODIMP
 FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
 {
   LOG(("FTPChannelChild::AsyncOpen [this=%p]\n", this));
 
   NS_ENSURE_TRUE((gNeckoChild), NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(!static_cast<ContentChild*>(gNeckoChild->Manager())->
+                   IsShuttingDown(), NS_ERROR_FAILURE);
   NS_ENSURE_ARG_POINTER(listener);
   NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
   NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
 
   // Port checked in parent, but duplicate here so we can return with error
   // immediately, as we've done since before e10s.
   nsresult rv;
   rv = NS_CheckPortSafety(nsBaseChannel::URI()); // Need to disambiguate,
@@ -183,17 +186,17 @@ FTPChannelChild::AsyncOpen(::nsIStreamLi
   mListenerContext = aContext;
 
   // add ourselves to the load group. 
   if (mLoadGroup)
     mLoadGroup->AddRequest(this, nullptr);
 
   mozilla::ipc::AutoIPCStream autoStream;
   autoStream.Serialize(mUploadStream,
-                       static_cast<mozilla::dom::ContentChild*>(gNeckoChild->Manager()));
+                       static_cast<ContentChild*>(gNeckoChild->Manager()));
 
   FTPChannelOpenArgs openArgs;
   SerializeURI(nsBaseChannel::URI(), openArgs.uri());
   openArgs.startPos() = mStartPos;
   openArgs.entityID() = mEntityID;
   openArgs.uploadStream() = autoStream.TakeOptionalValue();
 
   nsCOMPtr<nsILoadInfo> loadInfo;
@@ -868,16 +871,20 @@ FTPChannelChild::Resume()
 
 //-----------------------------------------------------------------------------
 // FTPChannelChild::nsIChildChannel
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 FTPChannelChild::ConnectParent(uint32_t id)
 {
+  NS_ENSURE_TRUE((gNeckoChild), NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(!static_cast<ContentChild*>(gNeckoChild->Manager())->
+                   IsShuttingDown(), NS_ERROR_FAILURE);
+
   LOG(("FTPChannelChild::ConnectParent [this=%p]\n", this));
 
   mozilla::dom::TabChild* tabChild = nullptr;
   nsCOMPtr<nsITabChild> iTabChild;
   NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
                                 NS_GET_IID(nsITabChild),
                                 getter_AddRefs(iTabChild));
   GetCallback(iTabChild);
@@ -931,16 +938,18 @@ FTPChannelChild::CompleteRedirectSetup(n
 // FTPChannelChild::nsIDivertableChannel
 //-----------------------------------------------------------------------------
 NS_IMETHODIMP
 FTPChannelChild::DivertToParent(ChannelDiverterChild **aChild)
 {
   MOZ_RELEASE_ASSERT(aChild);
   MOZ_RELEASE_ASSERT(gNeckoChild);
   MOZ_RELEASE_ASSERT(!mDivertingToParent);
+  NS_ENSURE_TRUE(!static_cast<ContentChild*>(gNeckoChild->Manager())->
+                   IsShuttingDown(), NS_ERROR_FAILURE);
 
   LOG(("FTPChannelChild::DivertToParent [this=%p]\n", this));
 
   // We must fail DivertToParent() if there's no parent end of the channel (and
   // won't be!) due to early failure.
   if (NS_FAILED(mStatus) && !mIPCOpen) {
     return mStatus;
   }