| 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();
|
|
|