Bug 1050122 - Enable Nuwa on debug builds, and kill it if the preference is false. r=khuey
authorTing-Yu Chou <janus926@gmail.com>
Mon, 01 Sep 2014 10:43:39 +0800
changeset 203030 4f308fdd6ada6470a3431d9a75072b091a3df3a9
parent 202941 c360f3d1c00d73b0c1fb0a2c0da525cb55e58b83
child 203031 7fdbefd9f1dc81732c926449cfcfff8af3f04451
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerskhuey
bugs1050122
milestone34.0a1
Bug 1050122 - Enable Nuwa on debug builds, and kill it if the preference is false. r=khuey
b2g/app/B2GLoader.cpp
b2g/app/b2g.js
ipc/glue/ProcessUtils_linux.cpp
--- a/b2g/app/B2GLoader.cpp
+++ b/b2g/app/B2GLoader.cpp
@@ -210,16 +210,23 @@ RunProcesses(int argc, const char *argv[
     /* The Nuwa process */
     /* This provides the IPC service of loading Nuwa at the process.
      * The b2g process would send a IPC message of loading Nuwa
      * as the replacement of forking and executing plugin-container.
      */
     return XRE_ProcLoaderServiceRun(getppid(), childSock, argc, argv);
   }
 
+  // Reap zombie child process.
+  struct sigaction sa;
+  sa.sa_handler = SIG_IGN;
+  sigemptyset(&sa.sa_mask);
+  sa.sa_flags = 0;
+  sigaction(SIGCHLD, &sa, nullptr);
+
   // The b2g process
   int childPid = pid;
   XRE_ProcLoaderClientInit(childPid, parentSock);
   return b2g_main(argc, argv);
 }
 
 /**
  * B2G Loader is responsible for loading the b2g process and the
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -749,23 +749,21 @@ pref("hal.gonk.COMPOSITOR.nice", 0);
 // order to free up memory.
 pref("hal.processPriorityManager.gonk.notifyLowMemUnderKB", 14336);
 
 // We wait this long before polling the memory-pressure fd after seeing one
 // memory pressure event.  (When we're not under memory pressure, we sit
 // blocked on a poll(), and this pref has no effect.)
 pref("gonk.systemMemoryPressureRecoveryPollMS", 5000);
 
-#ifndef DEBUG
 // Enable pre-launching content processes for improved startup time
 // (hiding latency).
 pref("dom.ipc.processPrelaunch.enabled", true);
 // Wait this long before pre-launching a new subprocess.
 pref("dom.ipc.processPrelaunch.delayMs", 5000);
-#endif
 
 pref("dom.ipc.reuse_parent_app", false);
 
 // When a process receives a system message, we hold a CPU wake lock on its
 // behalf for this many seconds, or until it handles the system message,
 // whichever comes first.
 pref("dom.ipc.systemMessageCPULockTimeoutSec", 30);
 
--- a/ipc/glue/ProcessUtils_linux.cpp
+++ b/ipc/glue/ProcessUtils_linux.cpp
@@ -23,16 +23,17 @@
 #include "mozilla/ipc/Transport.h"
 #include "mozilla/ipc/FileDescriptorUtils.h"
 #include "mozilla/ipc/IOThreadChild.h"
 #include "mozilla/dom/ContentProcess.h"
 #include "base/file_descriptor_shuffle.h"
 #include "mozilla/BackgroundHangMonitor.h"
 #include "mozilla/DebugOnly.h"
 #include "base/process_util.h"
+#include "mozilla/Preferences.h"
 
 #include "prenv.h"
 
 #include "nsXULAppAPI.h" // export XRE_* functions
 
 #include "nsAppRunner.h"
 
 int content_process_main(int argc, char *argv[]);
@@ -176,16 +177,24 @@ ProcLoaderClientInit(pid_t aPeerPid, int
  */
 void
 ProcLoaderClientGeckoInit()
 {
   MOZ_ASSERT(sProcLoaderClientInitialized, "call ProcLoaderClientInit() at first");
   MOZ_ASSERT(!sProcLoaderClientGeckoInitialized,
              "call ProcLoaderClientGeckoInit() more than once");
 
+  if (!Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
+    kill(sProcLoaderPid, SIGKILL);
+    sProcLoaderPid = 0;
+    close(sProcLoaderChannelFd);
+    sProcLoaderChannelFd = -1;
+    return;
+  }
+
   sProcLoaderClientGeckoInitialized = true;
 
   FileDescriptor *fd = new FileDescriptor(sProcLoaderChannelFd);
   close(sProcLoaderChannelFd);
   sProcLoaderChannelFd = -1;
   Transport *transport = OpenDescriptor(*fd, Transport::MODE_CLIENT);
   sProcLoaderParent = new ProcLoaderParent(fd);
   sProcLoaderParent->Open(transport,