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

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

Issue 308013002: Pepper: Narrow locking at llc subprocess start. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h ('k') | 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 43e9fa557ccdfd3ee14a71340f6a981ca0d70698..416f15ec30c3dcff209418836aa75d195806e1c8 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc
@@ -54,6 +54,7 @@ void GetLlcCommandLine(Plugin* plugin,
PnaclTranslateThread::PnaclTranslateThread() : llc_subprocess_active_(false),
ld_subprocess_active_(false),
+ subprocesses_aborted_(false),
done_(false),
compile_time_(0),
obj_files_(NULL),
@@ -160,29 +161,36 @@ void PnaclTranslateThread::DoTranslate() {
llc_out_files.push_back(invalid_desc_wrapper_);
pp::Core* core = pp::Module::Get()->core();
+ int64_t llc_start_time = NaClGetTimeOfDayMicroseconds();
+ PP_FileHandle llc_file_handle = resources_->TakeLlcFileHandle();
+ NaClSubprocess* llc_subprocess = plugin_->LoadHelperNaClModule(
+ resources_->GetLlcUrl(), llc_file_handle, &error_info);
+ if (llc_subprocess == NULL) {
+ if (llc_file_handle != PP_kInvalidFileHandle)
+ CloseFileHandle(llc_file_handle);
+ TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP,
+ "Compile process could not be created: " +
+ error_info.message());
+ return;
+ }
+ core->CallOnMainThread(0,
+ coordinator_->GetUMATimeCallback(
+ "NaCl.Perf.PNaClLoadTime.LoadCompiler",
bbudge 2014/05/30 17:53:19 nit: indent arguments
+ NaClGetTimeOfDayMicroseconds() - llc_start_time),
+ PP_OK);
+
{
nacl::MutexLocker ml(&subprocess_mu_);
- int64_t llc_start_time = NaClGetTimeOfDayMicroseconds();
- PP_FileHandle llc_file_handle = resources_->TakeLlcFileHandle();
-
- // On success, ownership of llc_file_handle is transferred.
- llc_subprocess_.reset(plugin_->LoadHelperNaClModule(
- resources_->GetLlcUrl(), llc_file_handle, &error_info));
- if (llc_subprocess_.get() == NULL) {
- if (llc_file_handle != PP_kInvalidFileHandle)
- CloseFileHandle(llc_file_handle);
- TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP,
- "Compile 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_) {
+ llc_subprocess->service_runtime()->Shutdown();
+ delete llc_subprocess;
return;
}
-
+ llc_subprocess_.reset(llc_subprocess);
+ llc_subprocess = NULL;
llc_subprocess_active_ = true;
- core->CallOnMainThread(0,
- coordinator_->GetUMATimeCallback(
- "NaCl.Perf.PNaClLoadTime.LoadCompiler",
- NaClGetTimeOfDayMicroseconds() - llc_start_time),
- PP_OK);
}
int64_t compile_start_time = NaClGetTimeOfDayMicroseconds();
@@ -426,6 +434,7 @@ void PnaclTranslateThread::AbortSubprocesses() {
ld_subprocess_->service_runtime()->Shutdown();
ld_subprocess_active_ = false;
}
+ subprocesses_aborted_ = true;
NaClXMutexUnlock(&subprocess_mu_);
nacl::MutexLocker ml(&cond_mu_);
done_ = true;
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698