Bug 1255375 - MessagePort should not leak if DispatchMessage() fails, r=smaug a=ritu
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 10 Mar 2016 14:33:52 +0100
changeset 325341 5e9097f4bf87974241e6c1673c4a5633d888f9ad
parent 325340 88b29c784ee17f374c3e99ba41e35886bc8bc9de
child 325342 1e4a40c1c96c28e50030aee61a4fc14471bc8a98
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, ritu
bugs1255375
milestone47.0a2
Bug 1255375 - MessagePort should not leak if DispatchMessage() fails, r=smaug a=ritu MozReview-Commit-ID: LjGtQrf5Gnk
dom/messagechannel/MessagePort.cpp
--- a/dom/messagechannel/MessagePort.cpp
+++ b/dom/messagechannel/MessagePort.cpp
@@ -66,16 +66,20 @@ public:
   NS_IMETHOD
   Run() override
   {
     MOZ_ASSERT(mPort);
     MOZ_ASSERT(mPort->mPostMessageRunnable == this);
 
     nsresult rv = DispatchMessage();
 
+    // We must check if we were waiting for this message in order to shutdown
+    // the port.
+    mPort->UpdateMustKeepAlive();
+
     mPort->mPostMessageRunnable = nullptr;
     mPort->Dispatch();
 
     return rv;
   }
 
   NS_IMETHOD
   Cancel() override
@@ -146,19 +150,16 @@ private:
     RefPtr<MessagePortList> portList =
       new MessagePortList(static_cast<dom::Event*>(event.get()),
                           ports);
     event->SetPorts(portList);
 
     bool dummy;
     mPort->DispatchEvent(static_cast<dom::Event*>(event.get()), &dummy);
 
-    // We must check if we were waiting for this message in order to shutdown
-    // the port.
-    mPort->UpdateMustKeepAlive();
     return NS_OK;
   }
 
 private:
   ~PostMessageRunnable()
   {}
 
   RefPtr<MessagePort> mPort;