OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #define NACL_LOG_MODULE_NAME "Plugin_ServiceRuntime" | 7 #define NACL_LOG_MODULE_NAME "Plugin_ServiceRuntime" |
8 | 8 |
9 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 9 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 | 51 |
52 namespace plugin { | 52 namespace plugin { |
53 | 53 |
54 OpenManifestEntryResource::~OpenManifestEntryResource() { | 54 OpenManifestEntryResource::~OpenManifestEntryResource() { |
55 } | 55 } |
56 | 56 |
57 PluginReverseInterface::PluginReverseInterface( | 57 PluginReverseInterface::PluginReverseInterface( |
58 nacl::WeakRefAnchor* anchor, | 58 nacl::WeakRefAnchor* anchor, |
59 PP_Instance pp_instance, | 59 PP_Instance pp_instance, |
60 ServiceRuntime* service_runtime, | 60 ServiceRuntime* service_runtime, |
61 pp::CompletionCallback init_done_cb, | 61 pp::CompletionCallback init_done_cb) |
62 pp::CompletionCallback crash_cb) | |
63 : anchor_(anchor), | 62 : anchor_(anchor), |
64 pp_instance_(pp_instance), | 63 pp_instance_(pp_instance), |
65 service_runtime_(service_runtime), | 64 service_runtime_(service_runtime), |
66 shutting_down_(false), | 65 shutting_down_(false), |
67 init_done_cb_(init_done_cb), | 66 init_done_cb_(init_done_cb) { |
68 crash_cb_(crash_cb) { | |
69 NaClXMutexCtor(&mu_); | 67 NaClXMutexCtor(&mu_); |
70 NaClXCondVarCtor(&cv_); | 68 NaClXCondVarCtor(&cv_); |
71 } | 69 } |
72 | 70 |
73 PluginReverseInterface::~PluginReverseInterface() { | 71 PluginReverseInterface::~PluginReverseInterface() { |
74 NaClCondVarDtor(&cv_); | 72 NaClCondVarDtor(&cv_); |
75 NaClMutexDtor(&mu_); | 73 NaClMutexDtor(&mu_); |
76 } | 74 } |
77 | 75 |
78 void PluginReverseInterface::ShutDown() { | 76 void PluginReverseInterface::ShutDown() { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 4, | 214 4, |
217 "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n"); | 215 "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n"); |
218 p->file_info->desc = -1; | 216 p->file_info->desc = -1; |
219 } | 217 } |
220 *p->op_complete_ptr = true; | 218 *p->op_complete_ptr = true; |
221 NaClXCondVarBroadcast(&cv_); | 219 NaClXCondVarBroadcast(&cv_); |
222 } | 220 } |
223 } | 221 } |
224 | 222 |
225 void PluginReverseInterface::ReportCrash() { | 223 void PluginReverseInterface::ReportCrash() { |
226 NaClLog(4, "PluginReverseInterface::ReportCrash\n"); | 224 // This is now handled through Chromium IPC. |
227 | |
228 if (crash_cb_.pp_completion_callback().func != NULL) { | |
229 NaClLog(4, "PluginReverseInterface::ReportCrash: invoking CB\n"); | |
230 pp::Module::Get()->core()->CallOnMainThread(0, crash_cb_, PP_OK); | |
231 // Clear the callback to avoid it gets invoked twice. | |
232 crash_cb_ = pp::CompletionCallback(); | |
233 } else { | |
234 NaClLog(1, | |
235 "PluginReverseInterface::ReportCrash:" | |
236 " crash_cb_ not valid, skipping\n"); | |
237 } | |
238 } | 225 } |
239 | 226 |
240 void PluginReverseInterface::ReportExitStatus(int exit_status) { | 227 void PluginReverseInterface::ReportExitStatus(int exit_status) { |
241 // We do nothing here; reporting exit status is handled through a separate | 228 // We do nothing here; reporting exit status is handled through a separate |
242 // embedder interface. | 229 // embedder interface. |
243 } | 230 } |
244 | 231 |
245 int64_t PluginReverseInterface::RequestQuotaForWrite( | 232 int64_t PluginReverseInterface::RequestQuotaForWrite( |
246 nacl::string file_id, int64_t offset, int64_t bytes_to_write) { | 233 nacl::string file_id, int64_t offset, int64_t bytes_to_write) { |
247 return bytes_to_write; | 234 return bytes_to_write; |
248 } | 235 } |
249 | 236 |
250 ServiceRuntime::ServiceRuntime(Plugin* plugin, | 237 ServiceRuntime::ServiceRuntime(Plugin* plugin, |
251 PP_Instance pp_instance, | 238 PP_Instance pp_instance, |
252 bool main_service_runtime, | 239 bool main_service_runtime, |
253 bool uses_nonsfi_mode, | 240 bool uses_nonsfi_mode, |
254 pp::CompletionCallback init_done_cb, | 241 pp::CompletionCallback init_done_cb) |
255 pp::CompletionCallback crash_cb) | |
256 : plugin_(plugin), | 242 : plugin_(plugin), |
257 pp_instance_(pp_instance), | 243 pp_instance_(pp_instance), |
258 main_service_runtime_(main_service_runtime), | 244 main_service_runtime_(main_service_runtime), |
259 uses_nonsfi_mode_(uses_nonsfi_mode), | 245 uses_nonsfi_mode_(uses_nonsfi_mode), |
260 reverse_service_(NULL), | 246 reverse_service_(NULL), |
261 anchor_(new nacl::WeakRefAnchor()), | 247 anchor_(new nacl::WeakRefAnchor()), |
262 rev_interface_(new PluginReverseInterface(anchor_, pp_instance, this, | 248 rev_interface_(new PluginReverseInterface(anchor_, pp_instance, this, |
263 init_done_cb, crash_cb)), | 249 init_done_cb)), |
264 start_sel_ldr_done_(false), | 250 start_sel_ldr_done_(false), |
265 start_nexe_done_(false), | 251 start_nexe_done_(false), |
266 nexe_started_ok_(false), | 252 nexe_started_ok_(false), |
267 bootstrap_channel_(NACL_INVALID_HANDLE) { | 253 bootstrap_channel_(NACL_INVALID_HANDLE) { |
268 NaClSrpcChannelInitialize(&command_channel_); | 254 NaClSrpcChannelInitialize(&command_channel_); |
269 NaClXMutexCtor(&mu_); | 255 NaClXMutexCtor(&mu_); |
270 NaClXCondVarCtor(&cond_); | 256 NaClXCondVarCtor(&cond_); |
271 } | 257 } |
272 | 258 |
273 bool ServiceRuntime::SetupCommandChannel() { | 259 bool ServiceRuntime::SetupCommandChannel() { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
481 | 467 |
482 bool ServiceRuntime::StartNexeInternal() { | 468 bool ServiceRuntime::StartNexeInternal() { |
483 if (!SetupCommandChannel()) | 469 if (!SetupCommandChannel()) |
484 return false; | 470 return false; |
485 if (!InitReverseService()) | 471 if (!InitReverseService()) |
486 return false; | 472 return false; |
487 return StartModule(); | 473 return StartModule(); |
488 } | 474 } |
489 | 475 |
490 void ServiceRuntime::ReapLogs() { | 476 void ServiceRuntime::ReapLogs() { |
477 // TODO(teravest): Now that crashes are reported over Chrome IPC instead of | |
Mark Seaborn
2014/08/28 20:58:39
Nit: "reported over" -> "detected via"
since the
teravest
2014/09/03 15:18:22
I've reworked this whole block since it was confus
| |
478 // through the reverse service, allow the service runtime to crash itself | |
Mark Seaborn
2014/08/28 20:58:39
Nit: "service runtime" -> "NaCl process" or "servi
teravest
2014/09/03 15:18:22
Done.
| |
479 // when a module fails to start. | |
Mark Seaborn
2014/08/28 20:58:39
I find this paragraph a bit confusing. It says "N
teravest
2014/09/03 15:18:22
Yes, that's what I meant by the TODO. Is it cleare
| |
480 // | |
481 // The reasoning behind the current code behavior (dependent on the service | |
482 // runtime and reverse service) follows: | |
491 // On a load failure the service runtime does not crash itself to | 483 // On a load failure the service runtime does not crash itself to |
492 // avoid a race where the no-more-senders error on the reverse | 484 // avoid a race where the no-more-senders error on the reverse |
493 // channel service thread might cause the crash-detection logic to | 485 // channel service thread might cause the crash-detection logic to |
494 // kick in before the start_module RPC reply has been received. So | 486 // kick in before the start_module RPC reply has been received. So |
495 // we induce a service runtime crash here. We do not release | 487 // we induce a service runtime crash here. |
496 // subprocess_ since it's needed to collect crash log output after | |
497 // the error is reported. | |
498 RemoteLog(LOG_FATAL, "reap logs\n"); | 488 RemoteLog(LOG_FATAL, "reap logs\n"); |
499 if (NULL == reverse_service_) { | 489 |
500 // No crash detector thread. | 490 // TODO(teravest): Release subprocess_ here since it's no longer needed. It |
501 NaClLog(LOG_ERROR, "scheduling to get crash log\n"); | 491 // was previously kept around to collect crash log output from the bootstrap |
502 // Invoking rev_interface's method is workaround to avoid crash_cb | 492 // channel. |
503 // gets called twice or more. We should clean this up later. | |
504 rev_interface_->ReportCrash(); | |
Mark Seaborn
2014/08/28 20:58:39
It took me a while to understand this change.
Bas
teravest
2014/09/03 15:18:22
Done.
| |
505 NaClLog(LOG_ERROR, "should fire soon\n"); | |
506 } else { | |
507 NaClLog(LOG_ERROR, "Reverse service thread will pick up crash log\n"); | |
508 } | |
509 } | 493 } |
510 | 494 |
511 void ServiceRuntime::ReportLoadError(const ErrorInfo& error_info) { | 495 void ServiceRuntime::ReportLoadError(const ErrorInfo& error_info) { |
512 if (main_service_runtime_) { | 496 if (main_service_runtime_) { |
513 plugin_->ReportLoadError(error_info); | 497 plugin_->ReportLoadError(error_info); |
514 } | 498 } |
515 } | 499 } |
516 | 500 |
517 SrpcClient* ServiceRuntime::SetupAppChannel() { | 501 SrpcClient* ServiceRuntime::SetupAppChannel() { |
518 NaClLog(4, "ServiceRuntime::SetupAppChannel (subprocess_=%p)\n", | 502 NaClLog(4, "ServiceRuntime::SetupAppChannel (subprocess_=%p)\n", |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 reverse_service_->Unref(); | 561 reverse_service_->Unref(); |
578 | 562 |
579 rev_interface_->Unref(); | 563 rev_interface_->Unref(); |
580 | 564 |
581 anchor_->Unref(); | 565 anchor_->Unref(); |
582 NaClCondVarDtor(&cond_); | 566 NaClCondVarDtor(&cond_); |
583 NaClMutexDtor(&mu_); | 567 NaClMutexDtor(&mu_); |
584 } | 568 } |
585 | 569 |
586 } // namespace plugin | 570 } // namespace plugin |
OLD | NEW |