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 <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "native_client/src/public/imc_syscalls.h" | 9 #include "native_client/src/public/imc_syscalls.h" |
10 #include "native_client/src/shared/srpc/nacl_srpc.h" | 10 #include "native_client/src/shared/srpc/nacl_srpc.h" |
11 #include "native_client/src/shared/srpc/nacl_srpc_internal.h" | 11 #include "native_client/src/shared/srpc/nacl_srpc_internal.h" |
12 #include "native_client/src/shared/srpc/nacl_srpc_ppapi_plugin_internal.h" | |
13 | 12 |
14 #define BOUND_SOCKET 3 | 13 #define BOUND_SOCKET 3 |
15 | 14 |
16 | 15 |
17 int NaClSrpcAcceptClientConnection(const struct NaClSrpcHandlerDesc *methods) { | 16 int NaClSrpcAcceptClientConnection(const struct NaClSrpcHandlerDesc *methods) { |
18 int sock_fd = -1; | 17 int sock_fd = -1; |
19 int result = 1; | 18 int result = 1; |
20 | 19 |
21 NaClSrpcLog(1, "NaClSrpcAcceptClientConnection(methods=%p)\n", | 20 NaClSrpcLog(1, "NaClSrpcAcceptClientConnection(methods=%p)\n", |
22 (void*) methods); | 21 (void*) methods); |
23 NaClPluginLowLevelInitializationComplete(); | |
24 sock_fd = imc_accept(BOUND_SOCKET); | 22 sock_fd = imc_accept(BOUND_SOCKET); |
25 if (sock_fd == -1) { | 23 if (sock_fd == -1) { |
26 NaClSrpcLog(NACL_SRPC_LOG_ERROR, | 24 NaClSrpcLog(NACL_SRPC_LOG_ERROR, |
27 "NaClSrpcAcceptClientConnection: imc_accept failed.\n"); | 25 "NaClSrpcAcceptClientConnection: imc_accept failed.\n"); |
28 return 0; | 26 return 0; |
29 } | 27 } |
30 if (!NaClSrpcServerLoop(sock_fd, methods, NULL)) { | 28 if (!NaClSrpcServerLoop(sock_fd, methods, NULL)) { |
31 NaClSrpcLog(1, | 29 NaClSrpcLog(1, |
32 "NaClSrpcAcceptClientConnection: NaClSrpcServerLoop exited.\n"); | 30 "NaClSrpcAcceptClientConnection: NaClSrpcServerLoop exited.\n"); |
33 result = 0; | 31 result = 0; |
34 } | 32 } |
35 if (close(sock_fd) != 0) { | 33 if (close(sock_fd) != 0) { |
36 NaClSrpcLog(NACL_SRPC_LOG_ERROR, | 34 NaClSrpcLog(NACL_SRPC_LOG_ERROR, |
37 "NaClSrpcAcceptClientConnection: close failed.\n"); | 35 "NaClSrpcAcceptClientConnection: close failed.\n"); |
38 result = 0; | 36 result = 0; |
39 } | 37 } |
40 return result; | 38 return result; |
41 } | 39 } |
OLD | NEW |