Index: src/trusted/service_runtime/sel_ldr.c |
=================================================================== |
--- src/trusted/service_runtime/sel_ldr.c (revision 5616) |
+++ src/trusted/service_runtime/sel_ldr.c (working copy) |
@@ -124,6 +124,7 @@ |
nap->service_port = NULL; |
nap->service_address = NULL; |
nap->secure_service = NULL; |
+ nap->manifest_proxy = NULL; |
nap->reverse_client = NULL; |
nap->reverse_channel_initialized = 0; |
@@ -147,7 +148,7 @@ |
} |
if (!NaClNameServiceCtor(nap->name_service, |
NaClAddrSpSquattingThreadIfFactoryFunction, |
- nap)) { |
+ (void *) nap)) { |
free(nap->name_service); |
goto cleanup_cv; |
} |
@@ -1122,6 +1123,9 @@ |
int NaClSecureServiceCtor(struct NaClSecureService *self, |
struct NaClSrpcHandlerDesc const *srpc_handlers, |
struct NaClApp *nap) { |
+ NaClLog(4, |
+ "Entered NaClSecureServiceCtor: self 0x%"NACL_PRIxPTR"\n", |
+ (uintptr_t) self); |
if (!NaClSimpleServiceWithSocketCtor(&self->base, |
srpc_handlers, |
NaClThreadInterfaceThreadFactory, |
@@ -1147,14 +1151,6 @@ |
(*NACL_VTBL(NaClRefCount, self)->Dtor)(vself); |
} |
-/* fwd */ |
-int NaClSecureReverseClientCtor( |
- struct NaClSecureReverseClient *self, |
- void (*client_callback)( |
- void *, struct NaClThreadInterface *, struct NaClDesc *), |
- void *state, |
- struct NaClApp *nap); |
- |
/* |
* The first connection is performed by this callback handler. This |
* spawns a client thread that will bootstrap the other connections by |
@@ -1169,7 +1165,7 @@ |
static void NaClSecureReverseClientCallback( |
void *state, |
struct NaClThreadInterface *tif, |
- struct NaClDesc *conn) { |
+ struct NaClDesc *new_conn) { |
struct NaClSecureReverseClient *self = |
(struct NaClSecureReverseClient *) state; |
struct NaClApp *nap = self->nap; |
@@ -1185,7 +1181,7 @@ |
if (nap->reverse_channel_initialized) { |
NaClLog(LOG_FATAL, "Reverse channel already initialized\n"); |
} |
- if (!NaClSrpcClientCtor(&nap->reverse_channel, conn)) { |
+ if (!NaClSrpcClientCtor(&nap->reverse_channel, new_conn)) { |
NaClLog(LOG_FATAL, "Reverse channel SRPC Client Ctor failed\n"); |
} |
nap->reverse_channel_initialized = 1; |
@@ -1196,6 +1192,14 @@ |
NaClLog(4, "Leaving NaClSecureReverseClientCallback\n"); |
} |
+/* fwd */ |
+int NaClSecureReverseClientCtor( |
+ struct NaClSecureReverseClient *self, |
+ void (*client_callback)( |
+ void *, struct NaClThreadInterface *, struct NaClDesc *), |
+ void *state, |
+ struct NaClApp *nap); |
+ |
static void NaClSecureReverseClientSetup(struct NaClSrpcRpc *rpc, |
struct NaClSrpcArg **in_args, |
struct NaClSrpcArg **out_args, |
@@ -1225,10 +1229,14 @@ |
rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
goto done; |
} |
- nap->reverse_client = rev; |
+ nap->reverse_client = (struct NaClSecureReverseClient *) NaClRefCountRef( |
+ (struct NaClRefCount *) rev); |
out_args[0]->u.hval = NaClDescRef(rev->base.bound_and_cap[1]); |
rpc->result = NACL_SRPC_RESULT_OK; |
+ /* |
+ * Service thread takes the reference rev. |
+ */ |
if (!NaClSimpleRevClientStartServiceThread(&rev->base)) { |
NaClLog(LOG_FATAL, "Could not start reverse service thread\n"); |
} |
@@ -1283,17 +1291,18 @@ |
* server side spawn threads that asynchronously connect twice, in the |
* "incorrect" order, etc. |
*/ |
-static |
int NaClSecureReverseClientInsertHandler( |
struct NaClSecureReverseClient *self, |
- void (*h)(void *, |
- struct NaClThreadInterface *, |
- struct NaClDesc *), |
- void *d) { |
+ void (*handler)( |
+ void *handlr_state, |
+ struct NaClThreadInterface *thread_if, |
+ struct NaClDesc *new_conn), |
+ void *handler_state) { |
int retval; |
NaClXMutexLock(&self->mu); |
- retval = NaClSecureReverseClientInsertHandler_mu(self, h, d); |
+ retval = NaClSecureReverseClientInsertHandler_mu(self, |
+ handler, handler_state); |
NaClXMutexUnlock(&self->mu); |
return retval; |
} |
@@ -1438,7 +1447,7 @@ |
/* our instance_data is not connection specific */ |
return NaClSimpleServiceConnectionFactoryWithInstanceData( |
- vself, conn, (void*) self->nap, out); |
+ vself, conn, (void *) self->nap, out); |
} |
int NaClSecureServiceAcceptAndSpawnHandler(struct NaClSimpleService *vself) { |
@@ -1486,23 +1495,23 @@ |
}; |
-static void WINAPI ReverseTestThread(void *thread_state) { |
+static void WINAPI ReverseSetupThread(void *thread_state) { |
struct NaClApp *nap = (struct NaClApp *) thread_state; |
NaClSrpcError rpc_result; |
/* wait for reverse connection */ |
- NaClLog(1, "ReverseTestThread\n"); |
+ NaClLog(1, "ReverseSetupThread\n"); |
NaClXMutexLock(&nap->mu); |
while (!nap->reverse_channel_initialized) { |
- NaClLog(1, "ReverseTestThread waiting\n"); |
+ NaClLog(1, "ReverseSetupThread waiting\n"); |
NaClXCondVarWait(&nap->cv, &nap->mu); |
} |
- NaClLog(1, "ReverseTestThread initialized, making rpc\n"); |
+ NaClLog(1, "ReverseSetupThread initialized, making rpc\n"); |
rpc_result = NaClSrpcInvokeBySignature(&nap->reverse_channel, |
"test:s:", "Hello world"); |
if (NACL_SRPC_RESULT_OK != rpc_result) { |
NaClLog(LOG_ERROR, |
- "ReverseTestThread, test:s: rpc_result %d\n", |
+ "ReverseSetupThread, test:s: rpc_result %d\n", |
rpc_result); |
} |
NaClLog(4, |
@@ -1515,10 +1524,12 @@ |
NaClLog(4, "revlog returned %d.\n", rpc_result); |
if (NACL_SRPC_RESULT_OK != rpc_result) { |
NaClLog(LOG_ERROR, |
- "ReverseTestThread, revlog:s: rpc_result %d\n", |
+ "ReverseSetupThread, revlog:s: rpc_result %d\n", |
rpc_result); |
} |
NaClXMutexUnlock(&nap->mu); |
+ |
+ NaClThreadDtor(&nap->reverse_setup_thread); |
noelallen_use_chromium
2011/06/14 02:25:45
Safe?
bsy
2011/06/14 20:30:03
yes. the dtor does bookkeeping cleanup such as cl
noelallen_use_chromium
2011/06/14 22:08:14
That was actually a note to me to go check what Na
|
} |
@@ -1557,12 +1568,9 @@ |
"Could not start secure command channel service thread\n"); |
} |
- if (1) { |
- struct NaClThread thr; |
+ NaClThreadCtor(&nap->reverse_setup_thread, ReverseSetupThread, nap, |
+ NACL_KERN_STACK_SIZE); |
- NaClThreadCtor(&thr, ReverseTestThread, nap, NACL_KERN_STACK_SIZE); |
- } |
- |
NaClLog(4, "Leaving NaClSecureCommandChannel\n"); |
} |