Bug 1518923 - simplify subprocess handle duplication logic in PerformAsyncLaunch; r=bobowen
authorNathan Froyd <froydnj@mozilla.com>
Mon, 14 Jan 2019 11:01:48 -0500
changeset 510875 b3b520f039357af92792d733b0560404dc9c09ed
parent 510874 5214852dfc3c9a6a53e49225360bec20abe84dcc
child 510876 a70165566e3b178a252aae5046fbb48540c90dda
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobowen
bugs1518923
milestone66.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 1518923 - simplify subprocess handle duplication logic in PerformAsyncLaunch; r=bobowen Avoiding handle duplication for certain kinds of processes and allowing it for everything else seems to be what we're already doing, so let's make it easier to add new process types with that scheme in mind.
ipc/glue/GeckoChildProcessHost.cpp
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -1039,24 +1039,28 @@ bool GeckoChildProcessHost::PerformAsync
   } else
 #endif  // defined(MOZ_SANDBOX)
   {
     base::LaunchApp(cmdLine, *mLaunchOptions, &process);
 
 #ifdef MOZ_SANDBOX
     // We need to be able to duplicate handles to some types of non-sandboxed
     // child processes.
-    if (mProcessType == GeckoProcessType_Content ||
-        mProcessType == GeckoProcessType_GPU ||
-        mProcessType == GeckoProcessType_RDD ||
-        mProcessType == GeckoProcessType_VR ||
-        mProcessType == GeckoProcessType_GMPlugin) {
-      if (!mSandboxBroker.AddTargetPeer(process)) {
-        NS_WARNING("Failed to add content process as target peer.");
-      }
+    switch (mProcessType) {
+      case GeckoProcessType_Default:
+        MOZ_CRASH("shouldn't be launching a parent process");
+      case GeckoProcessType_Plugin:
+      case GeckoProcessType_IPDLUnitTest:
+        // No handle duplication necessary.
+        break;
+      default:
+        if (!mSandboxBroker.AddTargetPeer(process)) {
+          NS_WARNING("Failed to add child process as target peer.");
+        }
+        break;
     }
 #endif  // MOZ_SANDBOX
   }
 
 #else  // goes with defined(OS_POSIX)
 #error Sorry
 #endif  // defined(OS_POSIX)