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

Side by Side Diff: src/trusted/service_runtime/sel_main_chrome.c

Issue 1089323006: Add a load_status callback hook that is invoked at the end of chrome LoadApp. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: review Created 5 years, 8 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
« src/public/chrome_main.h ('K') | « src/public/chrome_main.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 /* 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
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
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 /*
380 * If there is a secure command channel, we sent an RPC reply with 384 * If there is a load status callback, call that now. TODO(jvoung): remove
381 * the reason that the nexe was rejected. If we exit now, that 385 * NaClBlockIfCommandChannelExists() and use the callback to indicate
382 * reply may still be in-flight and the various channel closure (esp 386 * the load_status.
Mark Seaborn 2015/04/18 01:14:14 Nit: "... after Chromium no longer calls start_mod
jvoung (off chromium) 2015/04/20 18:49:47 Done. Hmm there is still a race condition if I le
383 * reverse channel) may be detected first. This would result in a 387 */
384 * crash being reported, rather than the error in the RPC reply. 388 if (args->load_status_handler_func != NULL) {
389 /* Don't return LOAD_OK if we had some failure loading. */
390 if (LOAD_OK == errcode) {
391 errcode = LOAD_INTERNAL;
392 }
393 args->load_status_handler_func(errcode);
394 NaClLog(LOG_ERROR, "reap logs\n");
Mark Seaborn 2015/04/18 01:14:14 Can you put a less cryptic message here, please?
jvoung (off chromium) 2015/04/20 18:49:47 Done.
395 NaClLogRunAbortBehavior();
396 return errcode;
397 }
398 /*
399 * If there is no load status callback, but there is a secure command channel,
400 * we sent an RPC reply with the reason that the nexe was rejected.
401 * If we exit now, that reply may still be in-flight and the various
402 * channel closure (esp reverse channel) may be detected first. This would
403 * result in a crash being reported, rather than the error in the RPC reply.
385 * Instead, we wait for the hard-shutdown on the command channel. 404 * Instead, we wait for the hard-shutdown on the command channel.
386 */ 405 */
387 if (LOAD_OK != errcode) { 406 if (LOAD_OK != errcode) {
388 NaClBlockIfCommandChannelExists(nap); 407 NaClBlockIfCommandChannelExists(nap);
389 } else { 408 } else {
390 /* 409 /*
391 * Don't return LOAD_OK if we had some failure loading. 410 * Don't return LOAD_OK if we had some failure loading.
392 */ 411 */
393 errcode = LOAD_INTERNAL; 412 errcode = LOAD_INTERNAL;
394 } 413 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 int NaClChromeMainStart(struct NaClApp *nap, 457 int NaClChromeMainStart(struct NaClApp *nap,
439 struct NaClChromeMainArgs *args, 458 struct NaClChromeMainArgs *args,
440 int *exit_status) { 459 int *exit_status) {
441 int load_ok = LOAD_OK == LoadApp(nap, args); 460 int load_ok = LOAD_OK == LoadApp(nap, args);
442 if (load_ok) { 461 if (load_ok) {
443 *exit_status = StartApp(nap, args); 462 *exit_status = StartApp(nap, args);
444 } 463 }
445 free(args); 464 free(args);
446 return load_ok; 465 return load_ok;
447 } 466 }
OLDNEW
« src/public/chrome_main.h ('K') | « src/public/chrome_main.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698