From 5c096b1116bb81f9dde31fee1663c13598f2e855 Mon Sep 17 00:00:00 2001 From: "nsylvain@chromium.org" Date: Mon, 1 Feb 2010 18:28:26 +0000 Subject: Add a DCHECK to make sure that SpawnTarget is not called from multiple threads. In chrome all child processes are started from the PROCESS_LAUNCHER thread. BUG=28798 Review URL: http://codereview.chromium.org/548192 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37712 0039d316-1c4b-4281-b951-d872f2087c98 --- sandbox/src/broker_services.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sandbox/src/broker_services.cc') diff --git a/sandbox/src/broker_services.cc b/sandbox/src/broker_services.cc index 2c53a42..4382f7e 100644 --- a/sandbox/src/broker_services.cc +++ b/sandbox/src/broker_services.cc @@ -227,6 +227,13 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path, if (!policy) return SBOX_ERROR_BAD_PARAMS; + // Even though the resources touched by SpawnTarget can be accessed in + // multiple threads, the method itself cannot be called from more than + // 1 thread. This is to protect the global variables used while setting up + // the child process. + static DWORD thread_id = ::GetCurrentThreadId(); + DCHECK(thread_id == ::GetCurrentThreadId()); + AutoLock lock(&lock_); // This downcast is safe as long as we control CreatePolicy() -- cgit v1.1