Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Unified Diff: ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc

Issue 308193004: Pepper: Narrow locking at ld subprocess start. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DCHECK Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc
index 75416a53848d492290c30aa175be5ecbd5df9a1f..f2b00af3e4604eff12d065a563e92577782abb35 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc
@@ -339,29 +339,38 @@ bool PnaclTranslateThread::RunLdSubprocess() {
nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper();
pp::Core* core = pp::Module::Get()->core();
+ int64_t ld_start_time = NaClGetTimeOfDayMicroseconds();
+ PP_FileHandle ld_file_handle = resources_->TakeLdFileHandle();
+ // On success, ownership of ld_file_handle is transferred.
+ nacl::scoped_ptr<NaClSubprocess> ld_subprocess(
+ plugin_->LoadHelperNaClModule(resources_->GetLlcUrl(),
+ ld_file_handle,
+ &error_info));
+ if (ld_subprocess.get() == NULL) {
+ if (ld_file_handle != PP_kInvalidFileHandle)
+ CloseFileHandle(ld_file_handle);
+ TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP,
+ "Link process could not be created: " +
+ error_info.message());
+ return false;
+ }
+ core->CallOnMainThread(0,
+ coordinator_->GetUMATimeCallback(
+ "NaCl.Perf.PNaClLoadTime.LoadLinker",
+ NaClGetTimeOfDayMicroseconds() - ld_start_time),
+ PP_OK);
+
{
- // Create LD process
nacl::MutexLocker ml(&subprocess_mu_);
- int64_t ld_start_time = NaClGetTimeOfDayMicroseconds();
- PP_FileHandle ld_file_handle = resources_->TakeLdFileHandle();
-
- // On success, ownership of ld_file_handle is transferred.
- ld_subprocess_.reset(plugin_->LoadHelperNaClModule(
- resources_->GetLdUrl(), ld_file_handle, &error_info));
- if (ld_subprocess_ == NULL) {
- if (ld_file_handle != PP_kInvalidFileHandle)
- CloseFileHandle(ld_file_handle);
- TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP,
- "Link process could not be created: " +
- error_info.message());
+ // If we received a call to AbortSubprocesses() before we had a chance to
+ // set llc_subprocess_, shut down and clean up the subprocess started here.
+ if (subprocesses_aborted_) {
+ ld_subprocess->service_runtime()->Shutdown();
return false;
}
+ DCHECK(ld_subprocess_.get() == NULL);
+ ld_subprocess_.swap(ld_subprocess);
ld_subprocess_active_ = true;
- core->CallOnMainThread(0,
- coordinator_->GetUMATimeCallback(
- "NaCl.Perf.PNaClLoadTime.LoadLinker",
- NaClGetTimeOfDayMicroseconds() - ld_start_time),
- PP_OK);
}
int64_t link_start_time = NaClGetTimeOfDayMicroseconds();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698