diff options
author | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-08 12:55:57 +0000 |
---|---|---|
committer | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-08 12:55:57 +0000 |
commit | c548be23f2319ad028468a4da335b0934184ee74 (patch) | |
tree | 2337bf58ddac5d13c9e36a688c701c317ed087c8 /chrome | |
parent | 5eaf62787c9cbe75a8e016666d6dddf592e693b1 (diff) | |
download | chromium_src-c548be23f2319ad028468a4da335b0934184ee74.zip chromium_src-c548be23f2319ad028468a4da335b0934184ee74.tar.gz chromium_src-c548be23f2319ad028468a4da335b0934184ee74.tar.bz2 |
Zygote: Clarify relationship between HandleForkRequest() and ChromeMain()
HandleForkRequest() returns to ChromeMain() multiple times, once per
fork(). Add comments to indicate this, because this type of control
flow is unusual.
HandleReapRequest() and HandleDidProcessCrash() never spawn a new
renderer, so remove the possibility that these can do "return true" to
do so.
Review URL: http://codereview.chromium.org/669065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40894 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/chrome_dll_main.cc | 1 | ||||
-rw-r--r-- | chrome/browser/zygote_main_linux.cc | 24 |
2 files changed, 14 insertions, 11 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index 60d5d6a..f0e0f82 100644 --- a/chrome/app/chrome_dll_main.cc +++ b/chrome/app/chrome_dll_main.cc @@ -736,6 +736,7 @@ int ChromeMain(int argc, char** argv) { #endif } else if (process_type == switches::kZygoteProcess) { #if defined(OS_POSIX) && !defined(OS_MACOSX) + // This function call can return multiple times, once per fork(). if (ZygoteMain(main_params)) { // Zygote::HandleForkRequest may have reallocated the command // line so update it here with the new version. diff --git a/chrome/browser/zygote_main_linux.cc b/chrome/browser/zygote_main_linux.cc index eef6b6d..6566135 100644 --- a/chrome/browser/zygote_main_linux.cc +++ b/chrome/browser/zygote_main_linux.cc @@ -86,6 +86,7 @@ class Zygote { } for (;;) { + // This function call can return multiple times, once per fork(). if (HandleRequestFromBrowser(kBrowserDescriptor)) return true; } @@ -123,15 +124,18 @@ class Zygote { if (pickle.ReadInt(&iter, &kind)) { switch (kind) { case ZygoteHost::kCmdFork: + // This function call can return multiple times, once per fork(). return HandleForkRequest(fd, pickle, iter, fds); case ZygoteHost::kCmdReap: if (!fds.empty()) break; - return HandleReapRequest(fd, pickle, iter); + HandleReapRequest(fd, pickle, iter); + return false; case ZygoteHost::kCmdDidProcessCrash: if (!fds.empty()) break; - return HandleDidProcessCrash(fd, pickle, iter); + HandleDidProcessCrash(fd, pickle, iter); + return false; default: NOTREACHED(); break; @@ -145,35 +149,33 @@ class Zygote { return false; } - bool HandleReapRequest(int fd, const Pickle& pickle, void* iter) { + void HandleReapRequest(int fd, const Pickle& pickle, void* iter) { base::ProcessId child; base::ProcessId actual_child; if (!pickle.ReadInt(&iter, &child)) { LOG(WARNING) << "Error parsing reap request from browser"; - return false; + return; } if (g_suid_sandbox_active) { actual_child = real_pids_to_sandbox_pids[child]; if (!actual_child) - return false; + return; real_pids_to_sandbox_pids.erase(child); } else { actual_child = child; } ProcessWatcher::EnsureProcessTerminated(actual_child); - - return false; } - bool HandleDidProcessCrash(int fd, const Pickle& pickle, void* iter) { + void HandleDidProcessCrash(int fd, const Pickle& pickle, void* iter) { base::ProcessHandle child; if (!pickle.ReadInt(&iter, &child)) { LOG(WARNING) << "Error parsing DidProcessCrash request from browser"; - return false; + return; } bool child_exited; @@ -189,8 +191,6 @@ class Zygote { write_pickle.WriteBool(did_crash); write_pickle.WriteBool(child_exited); HANDLE_EINTR(write(fd, write_pickle.data(), write_pickle.size())); - - return false; } // Handle a 'fork' request from the browser: this means that the browser @@ -263,6 +263,7 @@ class Zygote { CommandLine::Init(0, NULL); CommandLine::ForCurrentProcess()->InitFromArgv(args); CommandLine::SetProcTitle(); + // The fork() request is handled further up the call stack. return true; } else if (child < 0) { LOG(ERROR) << "Zygote could not fork"; @@ -646,5 +647,6 @@ bool ZygoteMain(const MainFunctionParams& params) { #endif // ARCH_CPU_X86_FAMILY Zygote zygote; + // This function call can return multiple times, once per fork(). return zygote.ProcessRequests(); } |