OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/posix/unix_domain_socket.h" | 5 #include "base/posix/unix_domain_socket.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <sys/uio.h> | 9 #include <sys/uio.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 ssize_t UnixDomainSocket::SendRecvMsg(int fd, | 104 ssize_t UnixDomainSocket::SendRecvMsg(int fd, |
105 uint8_t* reply, | 105 uint8_t* reply, |
106 unsigned max_reply_len, | 106 unsigned max_reply_len, |
107 int* result_fd, | 107 int* result_fd, |
108 const Pickle& request) { | 108 const Pickle& request) { |
109 int fds[2]; | 109 int fds[2]; |
110 | 110 |
111 // This socketpair is only used for the IPC and is cleaned up before | 111 // This socketpair is only used for the IPC and is cleaned up before |
112 // returning. | 112 // returning. |
113 if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) == -1) | 113 if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) == -1) |
114 return false; | 114 return -1; |
115 | 115 |
116 std::vector<int> fd_vector; | 116 std::vector<int> fd_vector; |
117 fd_vector.push_back(fds[1]); | 117 fd_vector.push_back(fds[1]); |
118 if (!SendMsg(fd, request.data(), request.size(), fd_vector)) { | 118 if (!SendMsg(fd, request.data(), request.size(), fd_vector)) { |
119 close(fds[0]); | 119 close(fds[0]); |
120 close(fds[1]); | 120 close(fds[1]); |
121 return -1; | 121 return -1; |
122 } | 122 } |
123 close(fds[1]); | 123 close(fds[1]); |
124 | 124 |
(...skipping 12 matching lines...) Expand all Loading... |
137 NOTREACHED(); | 137 NOTREACHED(); |
138 | 138 |
139 return -1; | 139 return -1; |
140 } | 140 } |
141 | 141 |
142 if (result_fd) | 142 if (result_fd) |
143 *result_fd = fd_vector.empty() ? -1 : fd_vector[0]; | 143 *result_fd = fd_vector.empty() ? -1 : fd_vector[0]; |
144 | 144 |
145 return reply_len; | 145 return reply_len; |
146 } | 146 } |
OLD | NEW |