From 47a47a32332ce09411d9a7d2ea6772a442fead82 Mon Sep 17 00:00:00 2001 From: Thinker Li Date: Wed, 12 Feb 2020 16:57:39 +0000 Subject: [PATCH] Bug 1609881 - Part 1: put the fork server behind a preference. r=gsvelto Differential Revision: https://phabricator.services.mozilla.com/D61141 --HG-- extra : moz-landing-system : lando --- ipc/chromium/src/base/process_util_linux.cc | 2 +- ipc/glue/ForkServiceChild.cpp | 9 ++++++--- ipc/glue/ForkServiceChild.h | 4 ++-- ipc/glue/GeckoChildProcessHost.cpp | 3 ++- modules/libpref/init/StaticPrefList.yaml | 7 +++++++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ipc/chromium/src/base/process_util_linux.cc b/ipc/chromium/src/base/process_util_linux.cc index cb4f30c728eb..dfae70f3e3fa 100644 --- a/ipc/chromium/src/base/process_util_linux.cc +++ b/ipc/chromium/src/base/process_util_linux.cc @@ -215,7 +215,7 @@ static bool LaunchAppWithForkServer(const std::vector& argv, bool LaunchApp(const std::vector& argv, const LaunchOptions& options, ProcessHandle* process_handle) { #if defined(MOZ_ENABLE_FORKSERVER) - if (options.use_forkserver) { + if (options.use_forkserver && ForkServiceChild::Get()) { return LaunchAppWithForkServer(argv, options, process_handle); } #endif diff --git a/ipc/glue/ForkServiceChild.cpp b/ipc/glue/ForkServiceChild.cpp index 86dc5cd5b590..6a08ca0fadc0 100644 --- a/ipc/glue/ForkServiceChild.cpp +++ b/ipc/glue/ForkServiceChild.cpp @@ -1,5 +1,5 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim: set ts=8 sts=4 et sw=4 tw=80: */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -8,6 +8,7 @@ #include "mozilla/ipc/IPDLParamTraits.h" #include "mozilla/Logging.h" #include "mozilla/ipc/GeckoChildProcessHost.h" +#include "mozilla/StaticPrefs_dom.h" #include #include @@ -124,7 +125,9 @@ already_AddRefed ForkServerLauncher::Create() { NS_IMETHODIMP ForkServerLauncher::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { - if (!mHaveStartedClient && strcmp(aTopic, NS_XPCOM_STARTUP_CATEGORY) == 0) { + if (!mHaveStartedClient && + strcmp(aTopic, NS_XPCOM_STARTUP_CATEGORY) == 0 && + StaticPrefs::dom_ipc_forkserver_enable_AtStartup()) { mHaveStartedClient = true; ForkServiceChild::StartForkServer(); diff --git a/ipc/glue/ForkServiceChild.h b/ipc/glue/ForkServiceChild.h index 1e6de0b82fbb..68ee906c26d2 100644 --- a/ipc/glue/ForkServiceChild.h +++ b/ipc/glue/ForkServiceChild.h @@ -1,5 +1,5 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim: set ts=8 sts=4 et sw=4 tw=80: */ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 8d365fdd3a94..618d9cf8dfd8 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -362,7 +362,8 @@ GeckoChildProcessHost::GeckoChildProcessHost(GeckoProcessType aProcessType, } #endif #if defined(MOZ_ENABLE_FORKSERVER) - if (aProcessType == GeckoProcessType_Content) { + if (aProcessType == GeckoProcessType_Content && + ForkServiceChild::Get()) { mLaunchOptions->use_forkserver = true; } #endif diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index ae65f21f09e2..c0669dab7a99 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1676,6 +1676,13 @@ value: 500 mirror: always +#ifdef MOZ_ENABLE_FORKSERVER +- name: dom.ipc.forkserver.enable + type: bool + value: false + mirror: once +#endif + # Whether or not to collect a paired minidump when force-killing a # content process. - name: dom.ipc.tabs.createKillHardCrashReports