Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client 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 #include "native_client/src/public/chrome_main.h" | 7 #include "native_client/src/public/chrome_main.h" |
| 8 | 8 |
| 9 #include "native_client/src/include/build_config.h" | 9 #include "native_client/src/include/build_config.h" |
| 10 #include "native_client/src/include/portability.h" | 10 #include "native_client/src/include/portability.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 #endif | 100 #endif |
| 101 #if NACL_WINDOWS | 101 #if NACL_WINDOWS |
| 102 args->debug_stub_server_port_selected_handler_func = NULL; | 102 args->debug_stub_server_port_selected_handler_func = NULL; |
| 103 #endif | 103 #endif |
| 104 args->create_memory_object_func = NULL; | 104 args->create_memory_object_func = NULL; |
| 105 args->validation_cache = NULL; | 105 args->validation_cache = NULL; |
| 106 #if NACL_WINDOWS | 106 #if NACL_WINDOWS |
| 107 args->broker_duplicate_handle_func = NULL; | 107 args->broker_duplicate_handle_func = NULL; |
| 108 args->attach_debug_exception_handler_func = NULL; | 108 args->attach_debug_exception_handler_func = NULL; |
| 109 #endif | 109 #endif |
| 110 args->load_status_handler_func = NULL; | |
| 110 #if NACL_LINUX || NACL_OSX | 111 #if NACL_LINUX || NACL_OSX |
| 111 args->number_of_cores = -1; /* unknown */ | 112 args->number_of_cores = -1; /* unknown */ |
| 112 #endif | 113 #endif |
| 113 #if NACL_LINUX | 114 #if NACL_LINUX |
| 114 args->prereserved_sandbox_size = 0; | 115 args->prereserved_sandbox_size = 0; |
| 115 #endif | 116 #endif |
| 116 args->nexe_desc = NULL; | 117 args->nexe_desc = NULL; |
| 117 | 118 |
| 118 args->argc = default_argc; | 119 args->argc = default_argc; |
| 119 args->argv = (char **) default_argv; | 120 args->argv = (char **) default_argv; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 if (!NaClDebugInit(nap)) { | 365 if (!NaClDebugInit(nap)) { |
| 365 goto done; | 366 goto done; |
| 366 } | 367 } |
| 367 #if NACL_WINDOWS | 368 #if NACL_WINDOWS |
| 368 if (NULL != args->debug_stub_server_port_selected_handler_func) { | 369 if (NULL != args->debug_stub_server_port_selected_handler_func) { |
| 369 args->debug_stub_server_port_selected_handler_func(nap->debug_stub_port); | 370 args->debug_stub_server_port_selected_handler_func(nap->debug_stub_port); |
| 370 } | 371 } |
| 371 #endif | 372 #endif |
| 372 } | 373 } |
| 373 | 374 |
| 375 if (args->load_status_handler_func != NULL) { | |
| 376 args->load_status_handler_func(LOAD_OK); | |
| 377 } | |
| 374 return LOAD_OK; | 378 return LOAD_OK; |
| 375 | 379 |
| 376 done: | 380 done: |
| 377 fflush(stdout); | 381 fflush(stdout); |
| 378 | 382 |
| 379 /* | 383 /* |
| 384 * If there is a load status callback, call that now and transfer logs | |
| 385 * in preparation for process exit. | |
| 386 */ | |
| 387 if (args->load_status_handler_func != NULL) { | |
| 388 /* Don't return LOAD_OK if we had some failure loading. */ | |
| 389 if (LOAD_OK == errcode) { | |
| 390 errcode = LOAD_INTERNAL; | |
| 391 } | |
| 392 args->load_status_handler_func(errcode); | |
| 393 NaClLog(LOG_ERROR, "NaCl LoadApp failed. Transferring logs before exit.\n"); | |
| 394 NaClLogRunAbortBehavior(); | |
| 395 /* Fall through and run NaClBlockIfCommandChannelExists. | |
|
Mark Seaborn
2015/04/21 16:41:23
Nit: Use the NaCl style for multiline comments, wi
jvoung (off chromium)
2015/04/21 17:10:09
Done.
| |
| 396 * TODO(jvoung): remove NaClBlockIfCommandChannelExists() and use the | |
| 397 * callback to indicate the load_status after Chromium no longer calls | |
| 398 * start_module. We also need to change Chromium so that it does not | |
| 399 * attempt to set up the command channel if there is a known load error. | |
| 400 * Otherwise there is a race between this processes's exit / load error | |
|
Mark Seaborn
2015/04/21 16:41:23
"process's"
jvoung (off chromium)
2015/04/21 17:10:09
Done.
| |
| 401 * reporting, and the command channel setup on the Chromium side (plus | |
| 402 * the associated reporting). Thus this could end up with two different | |
| 403 * load errors being reported (1) the real load error from here, and | |
| 404 * (2) the command channel setup failure because the process exited in | |
| 405 * the middle of setting up the command channel. | |
| 406 */ | |
| 407 } | |
| 408 /* | |
| 380 * If there is a secure command channel, we sent an RPC reply with | 409 * If there is a secure command channel, we sent an RPC reply with |
| 381 * the reason that the nexe was rejected. If we exit now, that | 410 * the reason that the nexe was rejected. If we exit now, that |
| 382 * reply may still be in-flight and the various channel closure (esp | 411 * reply may still be in-flight and the various channel closure (esp |
| 383 * reverse channel) may be detected first. This would result in a | 412 * reverse channel) may be detected first. This would result in a |
| 384 * crash being reported, rather than the error in the RPC reply. | 413 * crash being reported, rather than the error in the RPC reply. |
| 385 * Instead, we wait for the hard-shutdown on the command channel. | 414 * Instead, we wait for the hard-shutdown on the command channel. |
| 386 */ | 415 */ |
| 387 if (LOAD_OK != errcode) { | 416 if (LOAD_OK != errcode) { |
| 388 NaClBlockIfCommandChannelExists(nap); | 417 NaClBlockIfCommandChannelExists(nap); |
| 389 } else { | 418 } else { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 int NaClChromeMainStart(struct NaClApp *nap, | 467 int NaClChromeMainStart(struct NaClApp *nap, |
| 439 struct NaClChromeMainArgs *args, | 468 struct NaClChromeMainArgs *args, |
| 440 int *exit_status) { | 469 int *exit_status) { |
| 441 int load_ok = LOAD_OK == LoadApp(nap, args); | 470 int load_ok = LOAD_OK == LoadApp(nap, args); |
| 442 if (load_ok) { | 471 if (load_ok) { |
| 443 *exit_status = StartApp(nap, args); | 472 *exit_status = StartApp(nap, args); |
| 444 } | 473 } |
| 445 free(args); | 474 free(args); |
| 446 return load_ok; | 475 return load_ok; |
| 447 } | 476 } |
| OLD | NEW |