Backed out changeset 1cf54b6a1c90 (bug 1541114) for causing crashes a=backout
authorBogdan Tara <btara@mozilla.com>
Sat, 13 Apr 2019 00:58:11 +0300
changeset 469316 d501ed4e5616aa2077c5d581e05836fbc7008091
parent 469315 db6f9582aaa89b91c8dd5a5031b69e77aaf49f1e
child 469326 bb72c0829808c541c7779614f37c83739e87e25c
child 469354 10b758c2be41d7fce59d229cfdc1e7091ef0165b
push id35862
push userbtara@mozilla.com
push dateFri, 12 Apr 2019 21:58:55 +0000
treeherdermozilla-central@d501ed4e5616 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1541114
milestone68.0a1
backs out1cf54b6a1c902ef00b7b3b68c08a4b8aa61b8703
first release with
nightly linux32
d501ed4e5616 / 68.0a1 / 20190412215855 / files
nightly linux64
d501ed4e5616 / 68.0a1 / 20190412215855 / files
nightly mac
d501ed4e5616 / 68.0a1 / 20190412215855 / files
nightly win32
d501ed4e5616 / 68.0a1 / 20190412215855 / files
nightly win64
d501ed4e5616 / 68.0a1 / 20190412215855 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 1cf54b6a1c90 (bug 1541114) for causing crashes a=backout
dom/network/TCPServerSocketParent.cpp
dom/network/TCPSocket.cpp
dom/network/TCPSocketParent.cpp
dom/network/TCPSocketParent.h
--- a/dom/network/TCPServerSocketParent.cpp
+++ b/dom/network/TCPServerSocketParent.cpp
@@ -47,16 +47,18 @@ TCPServerSocketParent::TCPServerSocketPa
 
 TCPServerSocketParent::~TCPServerSocketParent() {}
 
 void TCPServerSocketParent::Init() {
   NS_ENSURE_SUCCESS_VOID(mServerSocket->Init());
 }
 
 nsresult TCPServerSocketParent::SendCallbackAccept(TCPSocketParent* socket) {
+  socket->AddIPDLReference();
+
   nsresult rv;
 
   nsString host;
   rv = socket->GetHost(host);
   if (NS_FAILED(rv)) {
     NS_ERROR("Failed to get host from nsITCPSocketParent");
     return NS_ERROR_FAILURE;
   }
@@ -65,20 +67,16 @@ nsresult TCPServerSocketParent::SendCall
   rv = socket->GetPort(&port);
   if (NS_FAILED(rv)) {
     NS_ERROR("Failed to get port from nsITCPSocketParent");
     return NS_ERROR_FAILURE;
   }
 
   if (mNeckoParent) {
     if (mNeckoParent->SendPTCPSocketConstructor(socket, host, port)) {
-      // Call |AddIPDLReference| after the consructor message is sent
-      // successfully, otherwise |socket| could be leaked.
-      socket->AddIPDLReference();
-
       mozilla::Unused << PTCPServerSocketParent::SendCallbackAccept(socket);
     } else {
       NS_ERROR("Sending data from PTCPSocketParent was failed.");
     }
   } else {
     NS_ERROR("The member value for NeckoParent is wrong.");
   }
   return NS_OK;
--- a/dom/network/TCPSocket.cpp
+++ b/dom/network/TCPSocket.cpp
@@ -381,17 +381,17 @@ void TCPSocket::NotifyCopyComplete(nsres
     nsCOMPtr<nsIInputStream> stream = mPendingData[i];
     uint64_t available = 0;
     if (NS_SUCCEEDED(stream->Available(&available))) {
       bufferedAmount += available;
     }
   }
   mBufferedAmount = bufferedAmount;
 
-  if (mSocketBridgeParent && mSocketBridgeParent->IPCOpen()) {
+  if (mSocketBridgeParent) {
     mozilla::Unused << mSocketBridgeParent->SendUpdateBufferedAmount(
         BufferedAmount(), mTrackingNumber);
   }
 
   if (NS_FAILED(aStatus)) {
     MaybeReportErrorAndCloseIfOpen(aStatus);
     return;
   }
@@ -441,17 +441,17 @@ void TCPSocket::ActivateTLS() {
   nsCOMPtr<nsISSLSocketControl> socketControl = do_QueryInterface(securityInfo);
   if (socketControl) {
     socketControl->StartTLS();
   }
 }
 
 NS_IMETHODIMP
 TCPSocket::FireErrorEvent(const nsAString& aName, const nsAString& aType) {
-  if (mSocketBridgeParent && mSocketBridgeParent->IPCOpen()) {
+  if (mSocketBridgeParent) {
     mSocketBridgeParent->FireErrorEvent(aName, aType, mReadyState);
     return NS_OK;
   }
 
   TCPSocketErrorEventInit init;
   init.mBubbles = false;
   init.mCancelable = false;
   init.mName = aName;
@@ -462,17 +462,17 @@ TCPSocket::FireErrorEvent(const nsAStrin
   MOZ_ASSERT(event);
   event->SetTrusted(true);
   DispatchEvent(*event);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TCPSocket::FireEvent(const nsAString& aType) {
-  if (mSocketBridgeParent && mSocketBridgeParent->IPCOpen()) {
+  if (mSocketBridgeParent) {
     mSocketBridgeParent->FireEvent(aType, mReadyState);
     return NS_OK;
   }
 
   AutoJSAPI api;
   if (NS_WARN_IF(!api.Init(GetOwnerGlobal()))) {
     return NS_ERROR_FAILURE;
   }
@@ -939,17 +939,17 @@ TCPSocket::OnDataAvailable(nsIRequest* a
     buffer.SetCapacity(aCount);
     uint32_t actual;
     nsresult rv = aStream->Read(reinterpret_cast<char*>(buffer.Elements()),
                                 aCount, &actual);
     NS_ENSURE_SUCCESS(rv, rv);
     MOZ_ASSERT(actual == aCount);
     buffer.SetLength(actual);
 
-    if (mSocketBridgeParent && mSocketBridgeParent->IPCOpen()) {
+    if (mSocketBridgeParent) {
       mSocketBridgeParent->FireArrayBufferDataEvent(buffer, mReadyState);
       return NS_OK;
     }
 
     AutoJSAPI api;
     if (!api.Init(GetOwnerGlobal())) {
       return NS_ERROR_FAILURE;
     }
@@ -962,17 +962,17 @@ TCPSocket::OnDataAvailable(nsIRequest* a
     FireDataEvent(cx, NS_LITERAL_STRING("data"), value);
     return NS_OK;
   }
 
   nsCString data;
   nsresult rv = mInputStreamScriptable->ReadBytes(aCount, data);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (mSocketBridgeParent && mSocketBridgeParent->IPCOpen()) {
+  if (mSocketBridgeParent) {
     mSocketBridgeParent->FireStringDataEvent(data, mReadyState);
     return NS_OK;
   }
 
   AutoJSAPI api;
   if (!api.Init(GetOwnerGlobal())) {
     return NS_ERROR_FAILURE;
   }
@@ -1001,18 +1001,16 @@ TCPSocket::OnStopRequest(nsIRequest* aRe
   }
 
   // We call this even if there is no error.
   MaybeReportErrorAndCloseIfOpen(aStatus);
   return NS_OK;
 }
 
 void TCPSocket::SetSocketBridgeParent(TCPSocketParent* aBridgeParent) {
-  MOZ_ASSERT(NS_IsMainThread());
-
   mSocketBridgeParent = aBridgeParent;
 }
 
 NS_IMETHODIMP
 TCPSocket::UpdateReadyState(uint32_t aReadyState) {
   MOZ_ASSERT(mSocketBridgeChild);
   mReadyState = static_cast<TCPReadyState>(aReadyState);
   return NS_OK;
--- a/dom/network/TCPSocketParent.cpp
+++ b/dom/network/TCPSocketParent.cpp
@@ -325,17 +325,16 @@ nsresult TCPSocketParent::GetPort(uint16
     return NS_ERROR_FAILURE;
   }
   *aPort = mSocket->Port();
   return NS_OK;
 }
 
 void TCPSocketParent::ActorDestroy(ActorDestroyReason why) {
   if (mSocket) {
-    mSocket->SetSocketBridgeParent(nullptr);
     mSocket->Close();
   }
   mSocket = nullptr;
 }
 
 mozilla::ipc::IPCResult TCPSocketParent::RecvRequestDelete() {
   mozilla::Unused << Send__delete__(this);
   return IPC_OK();
--- a/dom/network/TCPSocketParent.h
+++ b/dom/network/TCPSocketParent.h
@@ -29,18 +29,16 @@ class TCPSocket;
 class TCPSocketParentBase : public nsISupports {
  public:
   NS_DECL_CYCLE_COLLECTION_CLASS(TCPSocketParentBase)
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   void AddIPDLReference();
   void ReleaseIPDLReference();
 
-  bool IPCOpen() const { return mIPCOpen; }
-
  protected:
   TCPSocketParentBase();
   virtual ~TCPSocketParentBase();
 
   RefPtr<TCPSocket> mSocket;
   bool mIPCOpen;
 };