Bug 1048011 - Fix a race condition that causes PProcLoaderParent leak. r=khuey
authorCervantes Yu <cyu@mozilla.com>
Mon, 11 Aug 2014 15:50:20 +0800
changeset 202975 0a76964b8d8dc4f4e06748335731c1f02e8711e1
parent 202974 2cd12da0c4e6f60f53236eb4cc4061bebc892777
child 202976 e567693fa55fa2a072606b7faeecfad4798d83c5
push id48537
push usercyu@mozilla.com
push dateTue, 02 Sep 2014 10:25:47 +0000
treeherdermozilla-inbound@0a76964b8d8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1048011
milestone34.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 1048011 - Fix a race condition that causes PProcLoaderParent leak. r=khuey
ipc/glue/ProcessUtils_linux.cpp
--- a/ipc/glue/ProcessUtils_linux.cpp
+++ b/ipc/glue/ProcessUtils_linux.cpp
@@ -117,31 +117,40 @@ public:
                                 const int32_t &aCookie) MOZ_OVERRIDE;
 
   virtual void OnChannelError() MOZ_OVERRIDE;
 };
 
 void
 ProcLoaderParent::ActorDestroy(ActorDestroyReason aWhy)
 {
+  if (aWhy == AbnormalShutdown) {
+    NS_WARNING("ProcLoaderParent is destroyed abnormally.");
+  }
+
+  if (sProcLoaderClientOnDeinit) {
+    // Get error for closing while the channel is already error.
+    return;
+  }
+
+  // Destroy self asynchronously.
+  ProcLoaderClientDeinit();
 }
 
 static void
 _ProcLoaderParentDestroy(PProcLoaderParent *aLoader)
 {
-  aLoader->Close();
   delete aLoader;
   sProcLoaderClientOnDeinit = false;
 }
 
 bool
 ProcLoaderParent::RecvLoadComplete(const int32_t &aPid,
                                    const int32_t &aCookie)
 {
-  ProcLoaderClientDeinit();
   return true;
 }
 
 void
 ProcLoaderParent::OnChannelError()
 {
   if (sProcLoaderClientOnDeinit) {
     // Get error for closing while the channel is already error.