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

Unified Diff: src/trusted/service_runtime/sel_ldr_standard.c

Issue 7108031: this patch adds the manifest proxy server to sel_ldr and the manifest (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 6 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
Index: src/trusted/service_runtime/sel_ldr_standard.c
===================================================================
--- src/trusted/service_runtime/sel_ldr_standard.c (revision 5616)
+++ src/trusted/service_runtime/sel_ldr_standard.c (working copy)
@@ -24,7 +24,10 @@
#include "native_client/src/shared/platform/nacl_time.h"
#include "native_client/src/trusted/perf_counter/nacl_perf_counter.h"
+#include "native_client/src/trusted/manifest_name_service_proxy/manifest_proxy.h"
noelallen_use_chromium 2011/06/14 02:25:45 include order?
bsy 2011/06/14 20:30:03 Done.
+
#include "native_client/src/trusted/service_runtime/include/sys/errno.h"
+#include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
#include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h"
#include "native_client/src/trusted/service_runtime/elf_util.h"
@@ -37,6 +40,7 @@
#include "native_client/src/trusted/service_runtime/outer_sandbox.h"
#include "native_client/src/trusted/service_runtime/sel_memory.h"
#include "native_client/src/trusted/service_runtime/sel_ldr.h"
+#include "native_client/src/trusted/service_runtime/sel_ldr_thread_interface.h"
#include "native_client/src/trusted/service_runtime/sel_util.h"
#include "native_client/src/trusted/service_runtime/sel_addrspace.h"
@@ -522,8 +526,82 @@
}
int NaClAppLaunchServiceThreads(struct NaClApp *nap) {
+ struct NaClManifestProxy *manifest_proxy = NULL;
+ int rv;
+
NaClNameServiceLaunch(nap->name_service);
- return 1;
+
+ NaClXMutexLock(&nap->mu);
noelallen_use_chromium 2011/06/14 02:25:45 Comment? As is, this code appears racy... The var
bsy 2011/06/14 20:30:03 reverse_channel_initialized is set in the RPC hand
+ rv = !nap->reverse_channel_initialized;
+ NaClXMutexUnlock(&nap->mu);
+ if (rv) {
+ NaClLog(3,
+ ("NaClAppLaunchServiceThreads: no reverse channel;"
+ " NOT launching manifest proxy\n"));
+ goto done;
+ }
+
+ rv = 0;
+ /*
+ * Allocate/construct the manifest proxy without grabbing global
+ * locks.
+ */
+ NaClLog(3, "NaClAppLaunchServiceThreads: launching manifest proxy\n");
+
+ /*
+ * ReverseClientSetup RPC should be done via the command channel
+ * prior to the load_module / start_module RPCs, and
+ * occurs after that, so checking
+ * nap->reverse_client suffices for determining whether the proxy is
+ * exporting reverse services.
+ */
+ manifest_proxy = (struct NaClManifestProxy *) malloc(sizeof *manifest_proxy);
+ if (NULL == manifest_proxy) {
+ NaClLog(LOG_ERROR, "No memory for manifest proxy\n");
+ goto manifest_proxy_alloc_failure;
+ }
+ if (!NaClManifestProxyCtor(manifest_proxy,
+ NaClAddrSpSquattingThreadIfFactoryFunction,
+ (void *) nap,
+ nap)) {
+ NaClLog(LOG_ERROR, "ManifestProxyCtor failed\n");
+ goto manifest_proxy_ctor_failure;
+ }
+
+ /*
+ * StartThread requires lock.
noelallen_use_chromium 2011/06/14 02:25:45 Where is the lock this comment mentions?
bsy 2011/06/14 20:30:03 clarified.
+ */
+ if (!NaClSimpleServiceStartServiceThread((struct NaClSimpleService *)
+ manifest_proxy)) {
+ NaClLog(LOG_ERROR, "ManifestProxy start service failed\n");
+ NaClRefCountUnref((struct NaClRefCount *) manifest_proxy);
noelallen_use_chromium 2011/06/14 02:25:45 This is counter-intuitive. Internally NaClSimpleS
bsy 2011/06/14 20:30:03 any object of a NaClRefCount subclass, after it's
+ manifest_proxy = NULL;
+ goto manifest_proxy_start_failed;
+ }
+
+ NaClXMutexLock(&nap->mu);
+ CHECK(NULL == nap->manifest_proxy);
+
+ nap->manifest_proxy = manifest_proxy;
+ manifest_proxy = NULL;
+
+ NaClLog(3,
+ ("NaClAppLaunchServiceThreads: adding manifest proxy to"
+ " name service\n"));
+ (*NACL_VTBL(NaClNameService, nap->name_service)->
+ CreateDescEntry)(nap->name_service,
+ "manifest_proxy", NACL_ABI_O_RDWR,
+ NaClDescRef(nap->manifest_proxy->base.bound_and_cap[1]));
+
+ rv = 1;
+ NaClXMutexUnlock(&nap->mu);
+
+manifest_proxy_start_failed:
+manifest_proxy_ctor_failure:
+ free(manifest_proxy);
+manifest_proxy_alloc_failure:
+done:
+ return rv;
}
/*

Powered by Google App Engine
This is Rietveld 408576698