OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ipc/ipc_channel_posix.h" | 5 #include "ipc/ipc_channel_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
12 #include <sys/stat.h> | 12 #include <sys/stat.h> |
13 #include <sys/un.h> | 13 #include <sys/un.h> |
| 14 #include <unistd.h> |
14 | 15 |
15 #if defined(OS_OPENBSD) | 16 #if defined(OS_OPENBSD) |
16 #include <sys/uio.h> | 17 #include <sys/uio.h> |
17 #endif | 18 #endif |
18 | 19 |
19 #include <string> | 20 #include <string> |
20 #include <map> | 21 #include <map> |
21 | 22 |
22 #include "base/command_line.h" | 23 #include "base/command_line.h" |
23 #include "base/eintr_wrapper.h" | 24 #include "base/eintr_wrapper.h" |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 892 |
892 Channel::ChannelImpl::ReadState Channel::ChannelImpl::ReadData( | 893 Channel::ChannelImpl::ReadState Channel::ChannelImpl::ReadData( |
893 char* buffer, | 894 char* buffer, |
894 int buffer_len, | 895 int buffer_len, |
895 int* bytes_read) { | 896 int* bytes_read) { |
896 if (pipe_ == -1) | 897 if (pipe_ == -1) |
897 return READ_FAILED; | 898 return READ_FAILED; |
898 | 899 |
899 struct msghdr msg = {0}; | 900 struct msghdr msg = {0}; |
900 | 901 |
901 struct iovec iov = {buffer, buffer_len}; | 902 struct iovec iov = {buffer, static_cast<size_t>(buffer_len)}; |
902 msg.msg_iov = &iov; | 903 msg.msg_iov = &iov; |
903 msg.msg_iovlen = 1; | 904 msg.msg_iovlen = 1; |
904 | 905 |
905 msg.msg_control = input_cmsg_buf_; | 906 msg.msg_control = input_cmsg_buf_; |
906 | 907 |
907 // recvmsg() returns 0 if the connection has closed or EAGAIN if no data | 908 // recvmsg() returns 0 if the connection has closed or EAGAIN if no data |
908 // is waiting on the pipe. | 909 // is waiting on the pipe. |
909 #if defined(IPC_USES_READWRITE) | 910 #if defined(IPC_USES_READWRITE) |
910 if (fd_pipe_ >= 0) { | 911 if (fd_pipe_ >= 0) { |
911 *bytes_read = HANDLE_EINTR(read(pipe_, buffer, buffer_len)); | 912 *bytes_read = HANDLE_EINTR(read(pipe_, buffer, buffer_len)); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 | 1186 |
1186 | 1187 |
1187 #if defined(OS_LINUX) | 1188 #if defined(OS_LINUX) |
1188 // static | 1189 // static |
1189 void Channel::SetGlobalPid(int pid) { | 1190 void Channel::SetGlobalPid(int pid) { |
1190 ChannelImpl::SetGlobalPid(pid); | 1191 ChannelImpl::SetGlobalPid(pid); |
1191 } | 1192 } |
1192 #endif // OS_LINUX | 1193 #endif // OS_LINUX |
1193 | 1194 |
1194 } // namespace IPC | 1195 } // namespace IPC |
OLD | NEW |