| 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_linux.h" | 5 #include "base/posix/unix_domain_socket_linux.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
| 9 #include <sys/uio.h> | 9 #include <sys/uio.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 if (msg.msg_flags & MSG_TRUNC || msg.msg_flags & MSG_CTRUNC) { | 102 if (msg.msg_flags & MSG_TRUNC || msg.msg_flags & MSG_CTRUNC) { |
| 103 for (unsigned i = 0; i < wire_fds_len; ++i) | 103 for (unsigned i = 0; i < wire_fds_len; ++i) |
| 104 close(wire_fds[i]); | 104 close(wire_fds[i]); |
| 105 errno = EMSGSIZE; | 105 errno = EMSGSIZE; |
| 106 return -1; | 106 return -1; |
| 107 } | 107 } |
| 108 | 108 |
| 109 fds->resize(wire_fds_len); | 109 if (wire_fds) { |
| 110 memcpy(vector_as_array(fds), wire_fds, sizeof(int) * wire_fds_len); | 110 fds->resize(wire_fds_len); |
| 111 memcpy(vector_as_array(fds), wire_fds, sizeof(int) * wire_fds_len); |
| 112 } |
| 111 | 113 |
| 112 return r; | 114 return r; |
| 113 } | 115 } |
| 114 | 116 |
| 115 // static | 117 // static |
| 116 ssize_t UnixDomainSocket::SendRecvMsg(int fd, | 118 ssize_t UnixDomainSocket::SendRecvMsg(int fd, |
| 117 uint8_t* reply, | 119 uint8_t* reply, |
| 118 unsigned max_reply_len, | 120 unsigned max_reply_len, |
| 119 int* result_fd, | 121 int* result_fd, |
| 120 const Pickle& request) { | 122 const Pickle& request) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 NOTREACHED(); | 166 NOTREACHED(); |
| 165 | 167 |
| 166 return -1; | 168 return -1; |
| 167 } | 169 } |
| 168 | 170 |
| 169 if (result_fd) | 171 if (result_fd) |
| 170 *result_fd = fd_vector.empty() ? -1 : fd_vector[0]; | 172 *result_fd = fd_vector.empty() ? -1 : fd_vector[0]; |
| 171 | 173 |
| 172 return reply_len; | 174 return reply_len; |
| 173 } | 175 } |
| OLD | NEW |