diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-11 00:07:25 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-11 00:07:25 +0000 |
commit | d52d8bff0029726f8f6e21a425b770093b57fa6b (patch) | |
tree | 005774df70f223fd59c0ffafdb23eecadedc2739 /content/browser/child_process_launcher.cc | |
parent | c553dcdf53ca9d4c14dceab5102b6cada415e494 (diff) | |
download | chromium_src-d52d8bff0029726f8f6e21a425b770093b57fa6b.zip chromium_src-d52d8bff0029726f8f6e21a425b770093b57fa6b.tar.gz chromium_src-d52d8bff0029726f8f6e21a425b770093b57fa6b.tar.bz2 |
Revert 193486 "[Mac] Remove base::LaunchSynchronize and rewrite ..."
> [Mac] Remove base::LaunchSynchronize and rewrite content::MachBroker.
>
> This restructures the way MachBroker parent-child communication happens. Now,
> the MachBroker lock will be held for the duration of LaunchProcess until the
> PID is returned and inserted into the MachMap. Since the lock must also be
> acquired on the broker thread to insert the received task port into the
> MachMap, this ensures that the placeholder is always inserted before the task
> port.
>
> MachBroker has also been rewritten to use Mach IPC directly, rather than the C++
> wrappers in base/mach_ipc_mac.h. The wrappers are not flexible enough to allow
> the use of an audit trailer. This trailer is used to verify the PID of the
> sender of the check in message in the parent. Previously, this was done by
> another kernel trap, pid_for_task.
>
> BUG=179923
>
>
> Review URL: https://chromiumcodereview.appspot.com/13845008
TBR=rsesek@chromium.org
Review URL: https://codereview.chromium.org/14120002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/child_process_launcher.cc')
-rw-r--r-- | content/browser/child_process_launcher.cc | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc index bde7f93..66e7c83 100644 --- a/content/browser/child_process_launcher.cc +++ b/content/browser/child_process_launcher.cc @@ -266,30 +266,30 @@ class ChildProcessLauncher::Context options.fds_to_remap = &fds_to_map; #if defined(OS_MACOSX) - // Hold the MachBroker lock for the duration of LaunchProcess. The child - // will send its task port to the parent almost immediately after startup. - // The Mach message will be delivered to the parent, but updating the - // record of the launch will wait until after the placeholder PID is - // inserted below. This ensures that while the child process may send its - // port to the parent prior to the parent leaving LaunchProcess, the - // order in which the record in MachBroker is updated is correct. - MachBroker* broker = MachBroker::GetInstance(); - broker->GetLock().Acquire(); - - // Make sure the MachBroker is running, and inform it to expect a - // check-in from the new process. - broker->EnsureRunning(); + // Use synchronization to make sure that the MachBroker is ready to + // receive a check-in from the new process before the new process + // actually tries to check in. + base::LaunchSynchronizationHandle synchronization_handle; + options.synchronize = &synchronization_handle; #endif // defined(OS_MACOSX) bool launched = base::LaunchProcess(*cmd_line, options, &handle); #if defined(OS_MACOSX) - if (launched) - broker->AddPlaceholderForPid(handle); + if (launched) { + MachBroker* broker = MachBroker::GetInstance(); + { + base::AutoLock lock(broker->GetLock()); + + // Make sure the MachBroker is running, and inform it to expect a + // check-in from the new process. + broker->EnsureRunning(); + broker->AddPlaceholderForPid(handle); + } - // After updating the broker, release the lock and let the child's - // messasge be processed on the broker's thread. - broker->GetLock().Release(); + // Now that the MachBroker is ready, the child may continue. + base::LaunchSynchronize(synchronization_handle); + } #endif // defined(OS_MACOSX) if (!launched) |