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

Side by Side Diff: components/nacl/renderer/plugin/pnacl_translate_thread.cc

Issue 1128373005: PNaCl: Hold subprocess_mu while doing StartSrpcServices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « components/nacl/renderer/plugin/pnacl_translate_thread.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/nacl/renderer/plugin/pnacl_translate_thread.h" 5 #include "components/nacl/renderer/plugin/pnacl_translate_thread.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "components/nacl/renderer/plugin/plugin.h" 10 #include "components/nacl/renderer/plugin/plugin.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 NaClXMutexUnlock(&cond_mu_); 183 NaClXMutexUnlock(&cond_mu_);
184 } 184 }
185 185
186 void WINAPI PnaclTranslateThread::DoCompileThread(void* arg) { 186 void WINAPI PnaclTranslateThread::DoCompileThread(void* arg) {
187 PnaclTranslateThread* translator = 187 PnaclTranslateThread* translator =
188 reinterpret_cast<PnaclTranslateThread*>(arg); 188 reinterpret_cast<PnaclTranslateThread*>(arg);
189 translator->DoCompile(); 189 translator->DoCompile();
190 } 190 }
191 191
192 void PnaclTranslateThread::DoCompile() { 192 void PnaclTranslateThread::DoCompile() {
193 // If the main thread asked us to exit in between starting the thread
194 // and now, just leave now.
195 { 193 {
196 nacl::MutexLocker ml(&subprocess_mu_); 194 nacl::MutexLocker ml(&subprocess_mu_);
195 // If the main thread asked us to exit in between starting the thread
196 // and now, just leave now.
197 if (!compiler_subprocess_active_) 197 if (!compiler_subprocess_active_)
198 return; 198 return;
199 } 199 // Now that we are in helper thread, we can do the the blocking
200 200 // StartSrpcServices operation.
201 // Now that we are in helper thread, we can do the the blocking 201 if (!compiler_subprocess_->StartSrpcServices()) {
202 // StartSrpcServices operation. 202 TranslateFailed(
203 if (!compiler_subprocess_->StartSrpcServices()) { 203 PP_NACL_ERROR_SRPC_CONNECTION_FAIL,
204 TranslateFailed( 204 "SRPC connection failure for " + compiler_subprocess_->description());
205 PP_NACL_ERROR_SRPC_CONNECTION_FAIL, 205 return;
206 "SRPC connection failure for " + compiler_subprocess_->description()); 206 }
207 return;
208 } 207 }
209 208
210 SrpcParams params; 209 SrpcParams params;
211 std::vector<nacl::DescWrapper*> compile_out_files; 210 std::vector<nacl::DescWrapper*> compile_out_files;
212 size_t i; 211 size_t i;
213 for (i = 0; i < obj_files_->size(); i++) 212 for (i = 0; i < obj_files_->size(); i++)
214 compile_out_files.push_back((*obj_files_)[i]->write_wrapper()); 213 compile_out_files.push_back((*obj_files_)[i]->write_wrapper());
215 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) 214 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++)
216 compile_out_files.push_back(invalid_desc_wrapper_); 215 compile_out_files.push_back(invalid_desc_wrapper_);
217 216
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 core->CallOnMainThread(0, compile_finished_callback_, PP_OK); 330 core->CallOnMainThread(0, compile_finished_callback_, PP_OK);
332 } 331 }
333 332
334 void WINAPI PnaclTranslateThread::DoLinkThread(void* arg) { 333 void WINAPI PnaclTranslateThread::DoLinkThread(void* arg) {
335 PnaclTranslateThread* translator = 334 PnaclTranslateThread* translator =
336 reinterpret_cast<PnaclTranslateThread*>(arg); 335 reinterpret_cast<PnaclTranslateThread*>(arg);
337 translator->DoLink(); 336 translator->DoLink();
338 } 337 }
339 338
340 void PnaclTranslateThread::DoLink() { 339 void PnaclTranslateThread::DoLink() {
341 // If the main thread asked us to exit in between starting the thread
342 // and now, just leave now.
343 { 340 {
344 nacl::MutexLocker ml(&subprocess_mu_); 341 nacl::MutexLocker ml(&subprocess_mu_);
342 // If the main thread asked us to exit in between starting the thread
343 // and now, just leave now.
345 if (!ld_subprocess_active_) 344 if (!ld_subprocess_active_)
346 return; 345 return;
347 } 346 // Now that we are in helper thread, we can do the the blocking
348 347 // StartSrpcServices operation.
349 // Now that we are in helper thread, we can do the the blocking 348 if (!ld_subprocess_->StartSrpcServices()) {
350 // StartSrpcServices operation. 349 TranslateFailed(
351 if (!ld_subprocess_->StartSrpcServices()) { 350 PP_NACL_ERROR_SRPC_CONNECTION_FAIL,
352 TranslateFailed( 351 "SRPC connection failure for " + ld_subprocess_->description());
353 PP_NACL_ERROR_SRPC_CONNECTION_FAIL, 352 return;
354 "SRPC connection failure for " + ld_subprocess_->description()); 353 }
355 return;
356 } 354 }
357 355
358 SrpcParams params; 356 SrpcParams params;
359 std::vector<nacl::DescWrapper*> ld_in_files; 357 std::vector<nacl::DescWrapper*> ld_in_files;
360 size_t i; 358 size_t i;
361 for (i = 0; i < obj_files_->size(); i++) { 359 for (i = 0; i < obj_files_->size(); i++) {
362 // Reset object file for reading first. 360 // Reset object file for reading first.
363 if (!(*obj_files_)[i]->Reset()) { 361 if (!(*obj_files_)[i]->Reset()) {
364 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, 362 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP,
365 "Link process could not reset object file"); 363 "Link process could not reset object file");
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 AbortSubprocesses(); 456 AbortSubprocesses();
459 if (translate_thread_ != NULL) 457 if (translate_thread_ != NULL)
460 NaClThreadJoin(translate_thread_.get()); 458 NaClThreadJoin(translate_thread_.get());
461 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); 459 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n"));
462 NaClCondVarDtor(&buffer_cond_); 460 NaClCondVarDtor(&buffer_cond_);
463 NaClMutexDtor(&cond_mu_); 461 NaClMutexDtor(&cond_mu_);
464 NaClMutexDtor(&subprocess_mu_); 462 NaClMutexDtor(&subprocess_mu_);
465 } 463 }
466 464
467 } // namespace plugin 465 } // namespace plugin
OLDNEW
« no previous file with comments | « components/nacl/renderer/plugin/pnacl_translate_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698