| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 /* GetMsg simply returns a string in a character array. */ | 81 /* GetMsg simply returns a string in a character array. */ |
| 82 static void GetMsg(NaClSrpcRpc *rpc, | 82 static void GetMsg(NaClSrpcRpc *rpc, |
| 83 NaClSrpcArg **in_args, | 83 NaClSrpcArg **in_args, |
| 84 NaClSrpcArg **out_args, | 84 NaClSrpcArg **out_args, |
| 85 NaClSrpcClosure *done) { | 85 NaClSrpcClosure *done) { |
| 86 static char message[] = "Quidquid id est, timeo Danaos et dona ferentes"; | 86 static char message[] = "Quidquid id est, timeo Danaos et dona ferentes"; |
| 87 | 87 |
| 88 printf("ServerThread: GetMsg\n"); | 88 printf("ServerThread: GetMsg\n"); |
| 89 | 89 |
| 90 if (out_args[0]->u.caval.count >= strlen(message)) { | 90 if (out_args[0]->u.count >= strlen(message)) { |
| 91 strncpy(out_args[0]->u.caval.carr, message, strlen(message) + 1); | 91 strncpy(out_args[0]->arrays.carr, message, strlen(message) + 1); |
| 92 rpc->result = NACL_SRPC_RESULT_OK; | 92 rpc->result = NACL_SRPC_RESULT_OK; |
| 93 } else { | 93 } else { |
| 94 printf("GetMsg: u.caval.count %u is too small %u\n", | 94 printf("GetMsg: u.count %u is too small %u\n", |
| 95 (unsigned) out_args[0]->u.caval.count, | 95 (unsigned) out_args[0]->u.count, |
| 96 (unsigned) strlen(message)); | 96 (unsigned) strlen(message)); |
| 97 ++errors_seen; | 97 ++errors_seen; |
| 98 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 98 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 99 } | 99 } |
| 100 done->Run(done); | 100 done->Run(done); |
| 101 } | 101 } |
| 102 | 102 |
| 103 /* Shutdown stops the RPC service. */ | 103 /* Shutdown stops the RPC service. */ |
| 104 static void Shutdown(NaClSrpcRpc *rpc, | 104 static void Shutdown(NaClSrpcRpc *rpc, |
| 105 NaClSrpcArg **in_args, | 105 NaClSrpcArg **in_args, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 /* | 154 /* |
| 155 * TestSharedMemory tests the passing of shared memory regions. | 155 * TestSharedMemory tests the passing of shared memory regions. |
| 156 * It expects to receive a handle and a string. | 156 * It expects to receive a handle and a string. |
| 157 */ | 157 */ |
| 158 void TestSharedMemory(NaClSrpcRpc *rpc, | 158 void TestSharedMemory(NaClSrpcRpc *rpc, |
| 159 NaClSrpcArg **in_args, | 159 NaClSrpcArg **in_args, |
| 160 NaClSrpcArg **out_args, | 160 NaClSrpcArg **out_args, |
| 161 NaClSrpcClosure *done) { | 161 NaClSrpcClosure *done) { |
| 162 int desc = in_args[0]->u.hval; | 162 int desc = in_args[0]->u.hval; |
| 163 char* compare_string = in_args[1]->u.sval.str; | 163 char* compare_string = in_args[1]->arrays.str; |
| 164 char* map_addr; | 164 char* map_addr; |
| 165 struct stat st; | 165 struct stat st; |
| 166 | 166 |
| 167 printf("TestSharedMemory(%d, %s)\n", desc, compare_string); | 167 printf("TestSharedMemory(%d, %s)\n", desc, compare_string); |
| 168 if (fstat(desc, &st)) { | 168 if (fstat(desc, &st)) { |
| 169 printf("TestSharedMemory: fstat failed\n"); | 169 printf("TestSharedMemory: fstat failed\n"); |
| 170 ++errors_seen; | 170 ++errors_seen; |
| 171 } else { | 171 } else { |
| 172 size_t length = (size_t) st.st_size; | 172 size_t length = (size_t) st.st_size; |
| 173 printf("TestSharedMemory: fstat returned 0x%08x\n", length); | 173 printf("TestSharedMemory: fstat returned 0x%08x\n", length); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 * srpc_sockaddr.html tests this by doing | 234 * srpc_sockaddr.html tests this by doing |
| 235 * __defaultSocketAddress().connect(). So, rather than using | 235 * __defaultSocketAddress().connect(). So, rather than using |
| 236 * NaClSrpcAcceptClientConnection(), we handle multiple connections | 236 * NaClSrpcAcceptClientConnection(), we handle multiple connections |
| 237 * explicitly. | 237 * explicitly. |
| 238 */ | 238 */ |
| 239 while (1) { | 239 while (1) { |
| 240 assert(NaClSrpcAcceptClientOnThread(srpc_methods)); | 240 assert(NaClSrpcAcceptClientOnThread(srpc_methods)); |
| 241 } | 241 } |
| 242 NaClSrpcModuleFini(); | 242 NaClSrpcModuleFini(); |
| 243 } | 243 } |
| OLD | NEW |