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

Side by Side Diff: src/trusted/simple_service/nacl_simple_service.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 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/trusted/simple_service/nacl_simple_service.h" 7 #include "native_client/src/trusted/simple_service/nacl_simple_service.h"
8 8
9 #include "native_client/src/include/nacl_compiler_annotations.h" 9 #include "native_client/src/include/nacl_compiler_annotations.h"
10 10
(...skipping 13 matching lines...) Expand all
24 #include "native_client/src/trusted/service_runtime/include/sys/errno.h" 24 #include "native_client/src/trusted/service_runtime/include/sys/errno.h"
25 25
26 #include "native_client/src/trusted/threading/nacl_thread_interface.h" 26 #include "native_client/src/trusted/threading/nacl_thread_interface.h"
27 27
28 int NaClSimpleServiceConnectionCtor( 28 int NaClSimpleServiceConnectionCtor(
29 struct NaClSimpleServiceConnection *self, 29 struct NaClSimpleServiceConnection *self,
30 struct NaClSimpleService *server, 30 struct NaClSimpleService *server,
31 struct NaClDesc *conn, 31 struct NaClDesc *conn,
32 void *instance_data) { 32 void *instance_data) {
33 NaClLog(4, 33 NaClLog(4,
34 "NaClSimpleServiceConnectionCtor: this 0x%"NACL_PRIxPTR"\n", 34 "NaClSimpleServiceConnectionCtor: self 0x%"NACL_PRIxPTR"\n",
35 (uintptr_t) self); 35 (uintptr_t) self);
36 if (!NaClRefCountCtor((struct NaClRefCount *) self)) { 36 if (!NaClRefCountCtor((struct NaClRefCount *) self)) {
37 return 0; 37 return 0;
38 } 38 }
39 self->server = (struct NaClSimpleService *) NaClRefCountRef( 39 self->server = (struct NaClSimpleService *) NaClRefCountRef(
40 (struct NaClRefCount *) server); 40 (struct NaClRefCount *) server);
41 self->connected_socket = (struct NaClDesc *) NaClRefCountRef( 41 self->connected_socket = (struct NaClDesc *) NaClRefCountRef(
42 (struct NaClRefCount *) conn); 42 (struct NaClRefCount *) conn);
43 self->instance_data = instance_data; 43 self->instance_data = instance_data;
44 44
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 NaClRefCountUnref((struct NaClRefCount *) conn); 114 NaClRefCountUnref((struct NaClRefCount *) conn);
115 return (void *) NULL; 115 return (void *) NULL;
116 } 116 }
117 117
118 static int NaClSimpleServiceCtorIntern( 118 static int NaClSimpleServiceCtorIntern(
119 struct NaClSimpleService *self, 119 struct NaClSimpleService *self,
120 struct NaClSrpcHandlerDesc const *srpc_handlers, 120 struct NaClSrpcHandlerDesc const *srpc_handlers,
121 NaClThreadIfFactoryFunction thread_factory_fn, 121 NaClThreadIfFactoryFunction thread_factory_fn,
122 void *thread_factory_data) { 122 void *thread_factory_data) {
123 NaClLog(4, 123 NaClLog(4,
124 "NaClSimpleServiceCtorIntern, this 0x%"NACL_PRIxPTR"\n", 124 "NaClSimpleServiceCtorIntern, self 0x%"NACL_PRIxPTR"\n",
125 (uintptr_t) self); 125 (uintptr_t) self);
126 if (!NaClRefCountCtor((struct NaClRefCount *) self)) { 126 if (!NaClRefCountCtor((struct NaClRefCount *) self)) {
127 NaClLog(4, "NaClSimpleServiceCtorIntern: NaClRefCountCtor failed\n"); 127 NaClLog(4, "NaClSimpleServiceCtorIntern: NaClRefCountCtor failed\n");
128 return 0; 128 return 0;
129 } 129 }
130 self->handlers = srpc_handlers; 130 self->handlers = srpc_handlers;
131 self->thread_factory_fn = thread_factory_fn; 131 self->thread_factory_fn = thread_factory_fn;
132 self->thread_factory_data = thread_factory_data; 132 self->thread_factory_data = thread_factory_data;
133 self->acceptor = (struct NaClThreadInterface *) NULL; 133 self->acceptor = (struct NaClThreadInterface *) NULL;
134 134
135 self->base.vtbl = (struct NaClRefCountVtbl const *) &kNaClSimpleServiceVtbl; 135 self->base.vtbl = (struct NaClRefCountVtbl const *) &kNaClSimpleServiceVtbl;
136 NaClLog(4, "Leaving NaClSimpleServiceCtorIntern\n"); 136 NaClLog(4, "Leaving NaClSimpleServiceCtorIntern\n");
137 return 1; 137 return 1;
138 } 138 }
139 139
140 int NaClSimpleServiceCtor( 140 int NaClSimpleServiceCtor(
141 struct NaClSimpleService *self, 141 struct NaClSimpleService *self,
142 struct NaClSrpcHandlerDesc const *srpc_handlers, 142 struct NaClSrpcHandlerDesc const *srpc_handlers,
143 NaClThreadIfFactoryFunction thread_factory_fn, 143 NaClThreadIfFactoryFunction thread_factory_fn,
144 void *thread_factory_data) { 144 void *thread_factory_data) {
145 NaClLog(4, 145 NaClLog(4,
146 "NaClSimpleServiceCtor: this 0x%"NACL_PRIxPTR"\n", 146 "Entered NaClSimpleServiceCtor: self 0x%"NACL_PRIxPTR"\n",
147 (uintptr_t) self); 147 (uintptr_t) self);
148 148
149 if (0 != NaClCommonDescMakeBoundSock(self->bound_and_cap)) { 149 if (0 != NaClCommonDescMakeBoundSock(self->bound_and_cap)) {
150 return 0; 150 return 0;
151 } 151 }
152 if (!NaClSimpleServiceCtorIntern(self, srpc_handlers, 152 if (!NaClSimpleServiceCtorIntern(self, srpc_handlers,
153 thread_factory_fn, thread_factory_data)) { 153 thread_factory_fn, thread_factory_data)) {
154 NaClDescUnref(self->bound_and_cap[0]); 154 NaClDescUnref(self->bound_and_cap[0]);
155 NaClDescUnref(self->bound_and_cap[1]); 155 NaClDescUnref(self->bound_and_cap[1]);
156 return 0; 156 return 0;
157 } 157 }
158 return 1; 158 return 1;
159 } 159 }
160 160
161 int NaClSimpleServiceWithSocketCtor( 161 int NaClSimpleServiceWithSocketCtor(
162 struct NaClSimpleService *self, 162 struct NaClSimpleService *self,
163 struct NaClSrpcHandlerDesc const *srpc_handlers, 163 struct NaClSrpcHandlerDesc const *srpc_handlers,
164 NaClThreadIfFactoryFunction thread_factory_fn, 164 NaClThreadIfFactoryFunction thread_factory_fn,
165 void *thread_factory_data, 165 void *thread_factory_data,
166 struct NaClDesc *service_port, 166 struct NaClDesc *service_port,
167 struct NaClDesc *sock_addr) { 167 struct NaClDesc *sock_addr) {
168 NaClLog(4, 168 NaClLog(4,
169 "NaClSimpleServiceWithSocketCtor: this 0x%"NACL_PRIxPTR"\n", 169 "NaClSimpleServiceWithSocketCtor: self 0x%"NACL_PRIxPTR"\n",
170 (uintptr_t) self); 170 (uintptr_t) self);
171 if (!NaClSimpleServiceCtorIntern(self, srpc_handlers, 171 if (!NaClSimpleServiceCtorIntern(self, srpc_handlers,
172 thread_factory_fn, thread_factory_data)) { 172 thread_factory_fn, thread_factory_data)) {
173 return 0; 173 return 0;
174 } 174 }
175 self->bound_and_cap[0] = NaClDescRef(service_port); 175 self->bound_and_cap[0] = NaClDescRef(service_port);
176 self->bound_and_cap[1] = NaClDescRef(sock_addr); 176 self->bound_and_cap[1] = NaClDescRef(sock_addr);
177 177
178 return 1; 178 return 1;
179 } 179 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 status = (*NACL_VTBL(NaClSimpleService, self)->ConnectionFactory)( 270 status = (*NACL_VTBL(NaClSimpleService, self)->ConnectionFactory)(
271 self, 271 self,
272 connected_desc, 272 connected_desc,
273 &conn); 273 &conn);
274 if (0 != status) { 274 if (0 != status) {
275 NaClLog(4, "ConnectionFactory failed\n"); 275 NaClLog(4, "ConnectionFactory failed\n");
276 goto cleanup; 276 goto cleanup;
277 } 277 }
278 /* all okay! */ 278 /* all okay! */
279 NaClLog(4, "conn is 0x%"NACL_PRIxPTR"\n", (uintptr_t) conn); 279
280 NaClLog(4, "out is 0x%"NACL_PRIxPTR"\n", (uintptr_t) out); 280 NaClLog(4,
281 "NaClSimpleServiceAcceptConnection: conn is 0x%"NACL_PRIxPTR"\n",
282 (uintptr_t) conn);
283 NaClLog(4,
284 "NaClSimpleServiceAcceptConnection: out is 0x%"NACL_PRIxPTR"\n",
285 (uintptr_t) out);
281 *out = conn; 286 *out = conn;
282 status = 0; 287 status = 0;
283 cleanup: 288 cleanup:
284 NaClRefCountSafeUnref((struct NaClRefCount *) connected_desc); 289 NaClRefCountSafeUnref((struct NaClRefCount *) connected_desc);
285 NaClLog(4, "Leaving NaClSimpleServiceAcceptConnection, status %d\n", status); 290 NaClLog(4, "Leaving NaClSimpleServiceAcceptConnection, status %d\n", status);
286 return status; 291 return status;
287 } 292 }
288 293
289 int NaClSimpleServiceAcceptAndSpawnHandler( 294 int NaClSimpleServiceAcceptAndSpawnHandler(
290 struct NaClSimpleService *self) { 295 struct NaClSimpleService *self) {
291 struct NaClSimpleServiceConnection *conn = NULL; 296 struct NaClSimpleServiceConnection *conn = NULL;
292 int status; 297 int status;
293 298
294 NaClLog(4, "Entered NaClSimpleServiceAcceptAndSpawnHandler\n"); 299 NaClLog(4, "Entered NaClSimpleServiceAcceptAndSpawnHandler\n");
295 NaClLog(4, 300 NaClLog(4,
296 ("NaClSimpleServiceAcceptAndSpawnHandler:" 301 ("NaClSimpleServiceAcceptAndSpawnHandler:"
297 " &conn is 0x%"NACL_PRIxPTR"\n"), 302 " &conn is 0x%"NACL_PRIxPTR"\n"),
298 (uintptr_t) &conn); 303 (uintptr_t) &conn);
299 status = (*NACL_VTBL(NaClSimpleService, self)->AcceptConnection)( 304 status = (*NACL_VTBL(NaClSimpleService, self)->AcceptConnection)(
300 self, 305 self,
301 &conn); 306 &conn);
302 NaClLog(4, "AcceptConnection vfn returned %d\n", status); 307 NaClLog(4, "AcceptConnection vfn returned %d\n", status);
303 if (0 != status) { 308 if (0 != status) {
304 goto abort; 309 goto abort;
305 } 310 }
306 NaClLog(4, "conn is 0x%"NACL_PRIxPTR"\n", (uintptr_t) conn); 311 NaClLog(4,
312 "NaClSimpleServiceAcceptAndSpawnHandler: conn is 0x%"NACL_PRIxPTR"\n",
313 (uintptr_t) conn);
307 NaClLog(4, "NaClSimpleServiceAcceptAndSpawnHandler: spawning thread\n"); 314 NaClLog(4, "NaClSimpleServiceAcceptAndSpawnHandler: spawning thread\n");
308 315
309 CHECK(NULL == conn->thread); 316 CHECK(NULL == conn->thread);
310 317
311 /* ownership of |conn| reference is passed to the thread */ 318 /* ownership of |conn| reference is passed to the thread */
312 if (!NaClThreadInterfaceConstructAndStartThread( 319 if (!NaClThreadInterfaceConstructAndStartThread(
313 self->thread_factory_fn, 320 self->thread_factory_fn,
314 self->thread_factory_data, 321 self->thread_factory_data,
315 RpcHandlerBase, 322 RpcHandlerBase,
316 conn, 323 conn,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 NACL_KERN_STACK_SIZE, 375 NACL_KERN_STACK_SIZE,
369 &server->acceptor)) { 376 &server->acceptor)) {
370 NaClLog(4, "NaClSimpleServiceStartServiceThread: no thread\n"); 377 NaClLog(4, "NaClSimpleServiceStartServiceThread: no thread\n");
371 NaClRefCountUnref(&server->base); /* undo ref in Ctor call arglist */ 378 NaClRefCountUnref(&server->base); /* undo ref in Ctor call arglist */
372 server->acceptor = NULL; 379 server->acceptor = NULL;
373 return 0; 380 return 0;
374 } 381 }
375 NaClLog(4, "NaClSimpleServiceStartServiceThread: success\n"); 382 NaClLog(4, "NaClSimpleServiceStartServiceThread: success\n");
376 return 1; 383 return 1;
377 } 384 }
OLDNEW
« no previous file with comments | « src/trusted/service_runtime/service_runtime.gyp ('k') | src/trusted/threading/nacl_thread_interface.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698