OLD | NEW |
---|---|
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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 /* | 9 /* |
10 * NaCl Simple/secure ELF loader (NaCl SEL). | 10 * NaCl Simple/secure ELF loader (NaCl SEL). |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 nap->dynamic_regions_allocated = 0; | 117 nap->dynamic_regions_allocated = 0; |
118 nap->dynamic_delete_generation = 0; | 118 nap->dynamic_delete_generation = 0; |
119 | 119 |
120 nap->dynamic_mapcache_offset = 0; | 120 nap->dynamic_mapcache_offset = 0; |
121 nap->dynamic_mapcache_size = 0; | 121 nap->dynamic_mapcache_size = 0; |
122 nap->dynamic_mapcache_ret = 0; | 122 nap->dynamic_mapcache_ret = 0; |
123 | 123 |
124 nap->service_port = NULL; | 124 nap->service_port = NULL; |
125 nap->service_address = NULL; | 125 nap->service_address = NULL; |
126 nap->secure_service = NULL; | 126 nap->secure_service = NULL; |
127 nap->manifest_proxy = NULL; | |
127 nap->reverse_client = NULL; | 128 nap->reverse_client = NULL; |
128 nap->reverse_channel_initialized = 0; | 129 nap->reverse_channel_initialized = 0; |
129 | 130 |
130 if (!NaClMutexCtor(&nap->mu)) { | 131 if (!NaClMutexCtor(&nap->mu)) { |
131 goto cleanup_dynamic_load_mutex; | 132 goto cleanup_dynamic_load_mutex; |
132 } | 133 } |
133 if (!NaClCondVarCtor(&nap->cv)) { | 134 if (!NaClCondVarCtor(&nap->cv)) { |
134 goto cleanup_mu; | 135 goto cleanup_mu; |
135 } | 136 } |
136 | 137 |
137 nap->vm_hole_may_exist = 0; | 138 nap->vm_hole_may_exist = 0; |
138 nap->threads_launching = 0; | 139 nap->threads_launching = 0; |
139 | 140 |
140 nap->module_load_status = LOAD_STATUS_UNKNOWN; | 141 nap->module_load_status = LOAD_STATUS_UNKNOWN; |
141 nap->module_may_start = 0; /* only when secure_service != NULL */ | 142 nap->module_may_start = 0; /* only when secure_service != NULL */ |
142 | 143 |
143 nap->name_service = (struct NaClNameService *) malloc( | 144 nap->name_service = (struct NaClNameService *) malloc( |
144 sizeof *nap->name_service); | 145 sizeof *nap->name_service); |
145 if (NULL == nap->name_service) { | 146 if (NULL == nap->name_service) { |
146 goto cleanup_cv; | 147 goto cleanup_cv; |
147 } | 148 } |
148 if (!NaClNameServiceCtor(nap->name_service, | 149 if (!NaClNameServiceCtor(nap->name_service, |
149 NaClAddrSpSquattingThreadIfFactoryFunction, | 150 NaClAddrSpSquattingThreadIfFactoryFunction, |
150 nap)) { | 151 (void *) nap)) { |
151 free(nap->name_service); | 152 free(nap->name_service); |
152 goto cleanup_cv; | 153 goto cleanup_cv; |
153 } | 154 } |
154 nap->name_service_conn_cap = NaClDescRef(nap->name_service-> | 155 nap->name_service_conn_cap = NaClDescRef(nap->name_service-> |
155 base.base.bound_and_cap[1]); | 156 base.base.bound_and_cap[1]); |
156 if (!NaClDefaultNameServiceInit(nap->name_service)) { | 157 if (!NaClDefaultNameServiceInit(nap->name_service)) { |
157 goto cleanup_name_service; | 158 goto cleanup_name_service; |
158 } | 159 } |
159 | 160 |
160 nap->ignore_validator_result = 0; | 161 nap->ignore_validator_result = 0; |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1115 struct NaClConnectionHandler *queue_head; | 1116 struct NaClConnectionHandler *queue_head; |
1116 struct NaClConnectionHandler **queue_insert; | 1117 struct NaClConnectionHandler **queue_insert; |
1117 }; | 1118 }; |
1118 | 1119 |
1119 struct NaClSimpleRevClientVtbl const kNaClSecureReverseClientVtbl; | 1120 struct NaClSimpleRevClientVtbl const kNaClSecureReverseClientVtbl; |
1120 | 1121 |
1121 | 1122 |
1122 int NaClSecureServiceCtor(struct NaClSecureService *self, | 1123 int NaClSecureServiceCtor(struct NaClSecureService *self, |
1123 struct NaClSrpcHandlerDesc const *srpc_handlers, | 1124 struct NaClSrpcHandlerDesc const *srpc_handlers, |
1124 struct NaClApp *nap) { | 1125 struct NaClApp *nap) { |
1126 NaClLog(4, | |
1127 "Entered NaClSecureServiceCtor: self 0x%"NACL_PRIxPTR"\n", | |
1128 (uintptr_t) self); | |
1125 if (!NaClSimpleServiceWithSocketCtor(&self->base, | 1129 if (!NaClSimpleServiceWithSocketCtor(&self->base, |
1126 srpc_handlers, | 1130 srpc_handlers, |
1127 NaClThreadInterfaceThreadFactory, | 1131 NaClThreadInterfaceThreadFactory, |
1128 (void *) NULL, | 1132 (void *) NULL, |
1129 nap->service_port, | 1133 nap->service_port, |
1130 nap->service_address)) { | 1134 nap->service_address)) { |
1131 goto failure_simple_ctor; | 1135 goto failure_simple_ctor; |
1132 } | 1136 } |
1133 self->nap = nap; | 1137 self->nap = nap; |
1134 | 1138 |
1135 NACL_VTBL(NaClRefCount, self) = | 1139 NACL_VTBL(NaClRefCount, self) = |
1136 (struct NaClRefCountVtbl *) &kNaClSecureServiceVtbl; | 1140 (struct NaClRefCountVtbl *) &kNaClSecureServiceVtbl; |
1137 return 1; | 1141 return 1; |
1138 failure_simple_ctor: | 1142 failure_simple_ctor: |
1139 return 0; | 1143 return 0; |
1140 } | 1144 } |
1141 | 1145 |
1142 void NaClSecureServiceDtor(struct NaClRefCount *vself) { | 1146 void NaClSecureServiceDtor(struct NaClRefCount *vself) { |
1143 struct NaClSecureService *self = (struct NaClSecureService *) vself; | 1147 struct NaClSecureService *self = (struct NaClSecureService *) vself; |
1144 | 1148 |
1145 NACL_VTBL(NaClRefCount, self) = (struct NaClRefCountVtbl const *) | 1149 NACL_VTBL(NaClRefCount, self) = (struct NaClRefCountVtbl const *) |
1146 &kNaClSimpleServiceVtbl; | 1150 &kNaClSimpleServiceVtbl; |
1147 (*NACL_VTBL(NaClRefCount, self)->Dtor)(vself); | 1151 (*NACL_VTBL(NaClRefCount, self)->Dtor)(vself); |
1148 } | 1152 } |
1149 | 1153 |
1150 /* fwd */ | |
1151 int NaClSecureReverseClientCtor( | |
1152 struct NaClSecureReverseClient *self, | |
1153 void (*client_callback)( | |
1154 void *, struct NaClThreadInterface *, struct NaClDesc *), | |
1155 void *state, | |
1156 struct NaClApp *nap); | |
1157 | |
1158 /* | 1154 /* |
1159 * The first connection is performed by this callback handler. This | 1155 * The first connection is performed by this callback handler. This |
1160 * spawns a client thread that will bootstrap the other connections by | 1156 * spawns a client thread that will bootstrap the other connections by |
1161 * stashing the connection represented by |conn| to make reverse RPCs | 1157 * stashing the connection represented by |conn| to make reverse RPCs |
1162 * to ask the peer to connect to us. No thread is spawned; we just | 1158 * to ask the peer to connect to us. No thread is spawned; we just |
1163 * wrap access to the connection with a lock. | 1159 * wrap access to the connection with a lock. |
1164 * | 1160 * |
1165 * Subsequent connection callbacks will pass the connection to the | 1161 * Subsequent connection callbacks will pass the connection to the |
1166 * actual thread that made the connection request using |conn| | 1162 * actual thread that made the connection request using |conn| |
1167 * received in the first connection. | 1163 * received in the first connection. |
1168 */ | 1164 */ |
1169 static void NaClSecureReverseClientCallback( | 1165 static void NaClSecureReverseClientCallback( |
1170 void *state, | 1166 void *state, |
1171 struct NaClThreadInterface *tif, | 1167 struct NaClThreadInterface *tif, |
1172 struct NaClDesc *conn) { | 1168 struct NaClDesc *new_conn) { |
1173 struct NaClSecureReverseClient *self = | 1169 struct NaClSecureReverseClient *self = |
1174 (struct NaClSecureReverseClient *) state; | 1170 (struct NaClSecureReverseClient *) state; |
1175 struct NaClApp *nap = self->nap; | 1171 struct NaClApp *nap = self->nap; |
1176 | 1172 |
1177 UNREFERENCED_PARAMETER(tif); | 1173 UNREFERENCED_PARAMETER(tif); |
1178 | 1174 |
1179 NaClLog(4, "Entered NaClSecureReverseClientCallback\n"); | 1175 NaClLog(4, "Entered NaClSecureReverseClientCallback\n"); |
1180 | 1176 |
1181 NaClLog(4, " self=0x%"NACL_PRIxPTR"\n", (uintptr_t) self); | 1177 NaClLog(4, " self=0x%"NACL_PRIxPTR"\n", (uintptr_t) self); |
1182 NaClLog(4, " nap=0x%"NACL_PRIxPTR"\n", (uintptr_t) nap); | 1178 NaClLog(4, " nap=0x%"NACL_PRIxPTR"\n", (uintptr_t) nap); |
1183 NaClXMutexLock(&nap->mu); | 1179 NaClXMutexLock(&nap->mu); |
1184 | 1180 |
1185 if (nap->reverse_channel_initialized) { | 1181 if (nap->reverse_channel_initialized) { |
1186 NaClLog(LOG_FATAL, "Reverse channel already initialized\n"); | 1182 NaClLog(LOG_FATAL, "Reverse channel already initialized\n"); |
1187 } | 1183 } |
1188 if (!NaClSrpcClientCtor(&nap->reverse_channel, conn)) { | 1184 if (!NaClSrpcClientCtor(&nap->reverse_channel, new_conn)) { |
1189 NaClLog(LOG_FATAL, "Reverse channel SRPC Client Ctor failed\n"); | 1185 NaClLog(LOG_FATAL, "Reverse channel SRPC Client Ctor failed\n"); |
1190 } | 1186 } |
1191 nap->reverse_channel_initialized = 1; | 1187 nap->reverse_channel_initialized = 1; |
1192 | 1188 |
1193 NaClXCondVarBroadcast(&nap->cv); | 1189 NaClXCondVarBroadcast(&nap->cv); |
1194 NaClXMutexUnlock(&nap->mu); | 1190 NaClXMutexUnlock(&nap->mu); |
1195 | 1191 |
1196 NaClLog(4, "Leaving NaClSecureReverseClientCallback\n"); | 1192 NaClLog(4, "Leaving NaClSecureReverseClientCallback\n"); |
1197 } | 1193 } |
1198 | 1194 |
1195 /* fwd */ | |
1196 int NaClSecureReverseClientCtor( | |
1197 struct NaClSecureReverseClient *self, | |
1198 void (*client_callback)( | |
1199 void *, struct NaClThreadInterface *, struct NaClDesc *), | |
1200 void *state, | |
1201 struct NaClApp *nap); | |
1202 | |
1199 static void NaClSecureReverseClientSetup(struct NaClSrpcRpc *rpc, | 1203 static void NaClSecureReverseClientSetup(struct NaClSrpcRpc *rpc, |
1200 struct NaClSrpcArg **in_args, | 1204 struct NaClSrpcArg **in_args, |
1201 struct NaClSrpcArg **out_args, | 1205 struct NaClSrpcArg **out_args, |
1202 struct NaClSrpcClosure *done) { | 1206 struct NaClSrpcClosure *done) { |
1203 struct NaClApp *nap = | 1207 struct NaClApp *nap = |
1204 (struct NaClApp *) rpc->channel->server_instance_data; | 1208 (struct NaClApp *) rpc->channel->server_instance_data; |
1205 struct NaClSecureReverseClient *rev; | 1209 struct NaClSecureReverseClient *rev; |
1206 | 1210 |
1207 UNREFERENCED_PARAMETER(in_args); | 1211 UNREFERENCED_PARAMETER(in_args); |
1208 NaClLog(4, "Entered NaClSecureReverseClientSetup\n"); | 1212 NaClLog(4, "Entered NaClSecureReverseClientSetup\n"); |
1209 if (NULL != nap->reverse_client) { | 1213 if (NULL != nap->reverse_client) { |
1210 NaClLog(LOG_FATAL, "Double reverse setup RPC\n"); | 1214 NaClLog(LOG_FATAL, "Double reverse setup RPC\n"); |
1211 } | 1215 } |
1212 rev = (struct NaClSecureReverseClient *) malloc(sizeof *rev); | 1216 rev = (struct NaClSecureReverseClient *) malloc(sizeof *rev); |
1213 if (NULL == rev) { | 1217 if (NULL == rev) { |
1214 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 1218 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
1215 goto done; | 1219 goto done; |
1216 } | 1220 } |
1217 NaClLog(4, | 1221 NaClLog(4, |
1218 "NaClSecureReverseClientSetup: invoking" | 1222 "NaClSecureReverseClientSetup: invoking" |
1219 " NaClSecureReverseClientCtor\n"); | 1223 " NaClSecureReverseClientCtor\n"); |
1220 if (!NaClSecureReverseClientCtor(rev, | 1224 if (!NaClSecureReverseClientCtor(rev, |
1221 NaClSecureReverseClientCallback, | 1225 NaClSecureReverseClientCallback, |
1222 (void *) rev, | 1226 (void *) rev, |
1223 nap)) { | 1227 nap)) { |
1224 free(rev); | 1228 free(rev); |
1225 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 1229 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
1226 goto done; | 1230 goto done; |
1227 } | 1231 } |
1228 nap->reverse_client = rev; | 1232 nap->reverse_client = (struct NaClSecureReverseClient *) NaClRefCountRef( |
1233 (struct NaClRefCount *) rev); | |
1229 out_args[0]->u.hval = NaClDescRef(rev->base.bound_and_cap[1]); | 1234 out_args[0]->u.hval = NaClDescRef(rev->base.bound_and_cap[1]); |
1230 rpc->result = NACL_SRPC_RESULT_OK; | 1235 rpc->result = NACL_SRPC_RESULT_OK; |
1231 | 1236 |
1237 /* | |
1238 * Service thread takes the reference rev. | |
1239 */ | |
1232 if (!NaClSimpleRevClientStartServiceThread(&rev->base)) { | 1240 if (!NaClSimpleRevClientStartServiceThread(&rev->base)) { |
1233 NaClLog(LOG_FATAL, "Could not start reverse service thread\n"); | 1241 NaClLog(LOG_FATAL, "Could not start reverse service thread\n"); |
1234 } | 1242 } |
1235 | 1243 |
1236 done: | 1244 done: |
1237 (*done->Run)(done); | 1245 (*done->Run)(done); |
1238 NaClLog(4, "Leaving NaClSecureReverseClientSetup\n"); | 1246 NaClLog(4, "Leaving NaClSecureReverseClientSetup\n"); |
1239 } | 1247 } |
1240 | 1248 |
1241 /* | 1249 /* |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1276 * doesn't wait for a handler, we don't need a condvar. | 1284 * doesn't wait for a handler, we don't need a condvar. |
1277 * | 1285 * |
1278 * We do not need to serialize on the handlers, since the | 1286 * We do not need to serialize on the handlers, since the |
1279 * RPC-server/IMC-client implementation should not distinguish one | 1287 * RPC-server/IMC-client implementation should not distinguish one |
1280 * connection from another: it is okay for two handlers to be | 1288 * connection from another: it is okay for two handlers to be |
1281 * inserted, and two connection request RPCs to be preformed | 1289 * inserted, and two connection request RPCs to be preformed |
1282 * (sequentially, since they are over a single channel), and have the | 1290 * (sequentially, since they are over a single channel), and have the |
1283 * server side spawn threads that asynchronously connect twice, in the | 1291 * server side spawn threads that asynchronously connect twice, in the |
1284 * "incorrect" order, etc. | 1292 * "incorrect" order, etc. |
1285 */ | 1293 */ |
1286 static | |
1287 int NaClSecureReverseClientInsertHandler( | 1294 int NaClSecureReverseClientInsertHandler( |
1288 struct NaClSecureReverseClient *self, | 1295 struct NaClSecureReverseClient *self, |
1289 void (*h)(void *, | 1296 void (*handler)( |
1290 struct NaClThreadInterface *, | 1297 void *handlr_state, |
1291 struct NaClDesc *), | 1298 struct NaClThreadInterface *thread_if, |
1292 void *d) { | 1299 struct NaClDesc *new_conn), |
1300 void *handler_state) { | |
1293 int retval; | 1301 int retval; |
1294 | 1302 |
1295 NaClXMutexLock(&self->mu); | 1303 NaClXMutexLock(&self->mu); |
1296 retval = NaClSecureReverseClientInsertHandler_mu(self, h, d); | 1304 retval = NaClSecureReverseClientInsertHandler_mu(self, |
1305 handler, handler_state); | |
1297 NaClXMutexUnlock(&self->mu); | 1306 NaClXMutexUnlock(&self->mu); |
1298 return retval; | 1307 return retval; |
1299 } | 1308 } |
1300 | 1309 |
1301 static | 1310 static |
1302 struct NaClConnectionHandler *NaClSecureReverseClientPopHandler( | 1311 struct NaClConnectionHandler *NaClSecureReverseClientPopHandler( |
1303 struct NaClSecureReverseClient *self) { | 1312 struct NaClSecureReverseClient *self) { |
1304 struct NaClConnectionHandler *head; | 1313 struct NaClConnectionHandler *head; |
1305 | 1314 |
1306 NaClLog(4, "Entered NaClSecureReverseClientPopHandler, acquiring lock\n"); | 1315 NaClLog(4, "Entered NaClSecureReverseClientPopHandler, acquiring lock\n"); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1431 | 1440 |
1432 int NaClSecureServiceConnectionFactory( | 1441 int NaClSecureServiceConnectionFactory( |
1433 struct NaClSimpleService *vself, | 1442 struct NaClSimpleService *vself, |
1434 struct NaClDesc *conn, | 1443 struct NaClDesc *conn, |
1435 struct NaClSimpleServiceConnection **out) { | 1444 struct NaClSimpleServiceConnection **out) { |
1436 struct NaClSecureService *self = | 1445 struct NaClSecureService *self = |
1437 (struct NaClSecureService *) vself; | 1446 (struct NaClSecureService *) vself; |
1438 | 1447 |
1439 /* our instance_data is not connection specific */ | 1448 /* our instance_data is not connection specific */ |
1440 return NaClSimpleServiceConnectionFactoryWithInstanceData( | 1449 return NaClSimpleServiceConnectionFactoryWithInstanceData( |
1441 vself, conn, (void*) self->nap, out); | 1450 vself, conn, (void *) self->nap, out); |
1442 } | 1451 } |
1443 | 1452 |
1444 int NaClSecureServiceAcceptAndSpawnHandler(struct NaClSimpleService *vself) { | 1453 int NaClSecureServiceAcceptAndSpawnHandler(struct NaClSimpleService *vself) { |
1445 int rv; | 1454 int rv; |
1446 | 1455 |
1447 NaClLog(4, | 1456 NaClLog(4, |
1448 "NaClSecureServiceAcceptAndSpawnHandler: invoking base class vfn\n"); | 1457 "NaClSecureServiceAcceptAndSpawnHandler: invoking base class vfn\n"); |
1449 rv = (*kNaClSimpleServiceVtbl.AcceptAndSpawnHandler)(vself); | 1458 rv = (*kNaClSimpleServiceVtbl.AcceptAndSpawnHandler)(vself); |
1450 if (0 != rv) { | 1459 if (0 != rv) { |
1451 NaClLog(LOG_FATAL, | 1460 NaClLog(LOG_FATAL, |
(...skipping 27 matching lines...) Expand all Loading... | |
1479 NaClSecureServiceRpcHandler, | 1488 NaClSecureServiceRpcHandler, |
1480 }; | 1489 }; |
1481 | 1490 |
1482 struct NaClSimpleRevClientVtbl const kNaClSecureReverseClientVtbl = { | 1491 struct NaClSimpleRevClientVtbl const kNaClSecureReverseClientVtbl = { |
1483 { | 1492 { |
1484 NaClSecureReverseClientDtor, | 1493 NaClSecureReverseClientDtor, |
1485 }, | 1494 }, |
1486 }; | 1495 }; |
1487 | 1496 |
1488 | 1497 |
1489 static void WINAPI ReverseTestThread(void *thread_state) { | 1498 static void WINAPI ReverseSetupThread(void *thread_state) { |
1490 struct NaClApp *nap = (struct NaClApp *) thread_state; | 1499 struct NaClApp *nap = (struct NaClApp *) thread_state; |
1491 NaClSrpcError rpc_result; | 1500 NaClSrpcError rpc_result; |
1492 | 1501 |
1493 /* wait for reverse connection */ | 1502 /* wait for reverse connection */ |
1494 NaClLog(1, "ReverseTestThread\n"); | 1503 NaClLog(1, "ReverseSetupThread\n"); |
1495 NaClXMutexLock(&nap->mu); | 1504 NaClXMutexLock(&nap->mu); |
1496 while (!nap->reverse_channel_initialized) { | 1505 while (!nap->reverse_channel_initialized) { |
1497 NaClLog(1, "ReverseTestThread waiting\n"); | 1506 NaClLog(1, "ReverseSetupThread waiting\n"); |
1498 NaClXCondVarWait(&nap->cv, &nap->mu); | 1507 NaClXCondVarWait(&nap->cv, &nap->mu); |
1499 } | 1508 } |
1500 NaClLog(1, "ReverseTestThread initialized, making rpc\n"); | 1509 NaClLog(1, "ReverseSetupThread initialized, making rpc\n"); |
1501 rpc_result = NaClSrpcInvokeBySignature(&nap->reverse_channel, | 1510 rpc_result = NaClSrpcInvokeBySignature(&nap->reverse_channel, |
1502 "test:s:", "Hello world"); | 1511 "test:s:", "Hello world"); |
1503 if (NACL_SRPC_RESULT_OK != rpc_result) { | 1512 if (NACL_SRPC_RESULT_OK != rpc_result) { |
1504 NaClLog(LOG_ERROR, | 1513 NaClLog(LOG_ERROR, |
1505 "ReverseTestThread, test:s: rpc_result %d\n", | 1514 "ReverseSetupThread, test:s: rpc_result %d\n", |
1506 rpc_result); | 1515 rpc_result); |
1507 } | 1516 } |
1508 NaClLog(4, | 1517 NaClLog(4, |
1509 "Hello world should be logged browser side, rpc_result %d.\n", | 1518 "Hello world should be logged browser side, rpc_result %d.\n", |
1510 rpc_result); | 1519 rpc_result); |
1511 rpc_result = NaClSrpcInvokeBySignature(&nap->reverse_channel, | 1520 rpc_result = NaClSrpcInvokeBySignature(&nap->reverse_channel, |
1512 "revlog:s:", | 1521 "revlog:s:", |
1513 ("Log message that should show up" | 1522 ("Log message that should show up" |
1514 " on the JavaScript console")); | 1523 " on the JavaScript console")); |
1515 NaClLog(4, "revlog returned %d.\n", rpc_result); | 1524 NaClLog(4, "revlog returned %d.\n", rpc_result); |
1516 if (NACL_SRPC_RESULT_OK != rpc_result) { | 1525 if (NACL_SRPC_RESULT_OK != rpc_result) { |
1517 NaClLog(LOG_ERROR, | 1526 NaClLog(LOG_ERROR, |
1518 "ReverseTestThread, revlog:s: rpc_result %d\n", | 1527 "ReverseSetupThread, revlog:s: rpc_result %d\n", |
1519 rpc_result); | 1528 rpc_result); |
1520 } | 1529 } |
1521 NaClXMutexUnlock(&nap->mu); | 1530 NaClXMutexUnlock(&nap->mu); |
1531 | |
1532 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
| |
1522 } | 1533 } |
1523 | 1534 |
1524 | 1535 |
1525 void NaClSecureCommandChannel(struct NaClApp *nap) { | 1536 void NaClSecureCommandChannel(struct NaClApp *nap) { |
1526 struct NaClSecureService *secure_command_server; | 1537 struct NaClSecureService *secure_command_server; |
1527 | 1538 |
1528 static struct NaClSrpcHandlerDesc const secure_handlers[] = { | 1539 static struct NaClSrpcHandlerDesc const secure_handlers[] = { |
1529 { "hard_shutdown::", NaClSecureChannelShutdownRpc, }, | 1540 { "hard_shutdown::", NaClSecureChannelShutdownRpc, }, |
1530 { "start_module::i", NaClSecureChannelStartModuleRpc, }, | 1541 { "start_module::i", NaClSecureChannelStartModuleRpc, }, |
1531 { "log:is:", NaClSecureChannelLog, }, | 1542 { "log:is:", NaClSecureChannelLog, }, |
(...skipping 18 matching lines...) Expand all Loading... | |
1550 } | 1561 } |
1551 nap->secure_service = secure_command_server; | 1562 nap->secure_service = secure_command_server; |
1552 | 1563 |
1553 NaClLog(4, "NaClSecureCommandChannel: starting service thread\n"); | 1564 NaClLog(4, "NaClSecureCommandChannel: starting service thread\n"); |
1554 if (!NaClSimpleServiceStartServiceThread((struct NaClSimpleService *) | 1565 if (!NaClSimpleServiceStartServiceThread((struct NaClSimpleService *) |
1555 secure_command_server)) { | 1566 secure_command_server)) { |
1556 NaClLog(LOG_FATAL, | 1567 NaClLog(LOG_FATAL, |
1557 "Could not start secure command channel service thread\n"); | 1568 "Could not start secure command channel service thread\n"); |
1558 } | 1569 } |
1559 | 1570 |
1560 if (1) { | 1571 NaClThreadCtor(&nap->reverse_setup_thread, ReverseSetupThread, nap, |
1561 struct NaClThread thr; | 1572 NACL_KERN_STACK_SIZE); |
1562 | |
1563 NaClThreadCtor(&thr, ReverseTestThread, nap, NACL_KERN_STACK_SIZE); | |
1564 } | |
1565 | 1573 |
1566 NaClLog(4, "Leaving NaClSecureCommandChannel\n"); | 1574 NaClLog(4, "Leaving NaClSecureCommandChannel\n"); |
1567 } | 1575 } |
1568 | 1576 |
1569 | 1577 |
1570 void NaClVmHoleWaitToStartThread(struct NaClApp *nap) { | 1578 void NaClVmHoleWaitToStartThread(struct NaClApp *nap) { |
1571 NaClXMutexLock(&nap->mu); | 1579 NaClXMutexLock(&nap->mu); |
1572 | 1580 |
1573 /* ensure no virtual memory hole may appear */ | 1581 /* ensure no virtual memory hole may appear */ |
1574 while (nap->vm_hole_may_exist) { | 1582 while (nap->vm_hole_may_exist) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1624 NaClSandboxMemoryStartForValgrind(mem_start); | 1632 NaClSandboxMemoryStartForValgrind(mem_start); |
1625 | 1633 |
1626 #ifdef __GNUC__ | 1634 #ifdef __GNUC__ |
1627 _ovly_debug_event (); | 1635 _ovly_debug_event (); |
1628 #endif | 1636 #endif |
1629 } | 1637 } |
1630 | 1638 |
1631 void NaClGdbHook(struct NaClApp const *nap) { | 1639 void NaClGdbHook(struct NaClApp const *nap) { |
1632 StopForDebuggerInit(nap->mem_start); | 1640 StopForDebuggerInit(nap->mem_start); |
1633 } | 1641 } |
OLD | NEW |