| 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 25 matching lines...) Expand all Loading... |
| 36 msg.msg_control = control_buffer; | 36 msg.msg_control = control_buffer; |
| 37 msg.msg_controllen = control_len; | 37 msg.msg_controllen = control_len; |
| 38 cmsg = CMSG_FIRSTHDR(&msg); | 38 cmsg = CMSG_FIRSTHDR(&msg); |
| 39 cmsg->cmsg_level = SOL_SOCKET; | 39 cmsg->cmsg_level = SOL_SOCKET; |
| 40 cmsg->cmsg_type = SCM_RIGHTS; | 40 cmsg->cmsg_type = SCM_RIGHTS; |
| 41 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); | 41 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); |
| 42 memcpy(CMSG_DATA(cmsg), &fds[0], sizeof(int) * fds.size()); | 42 memcpy(CMSG_DATA(cmsg), &fds[0], sizeof(int) * fds.size()); |
| 43 msg.msg_controllen = cmsg->cmsg_len; | 43 msg.msg_controllen = cmsg->cmsg_len; |
| 44 } | 44 } |
| 45 | 45 |
| 46 const ssize_t r = HANDLE_EINTR(sendmsg(fd, &msg, MSG_NOSIGNAL)); | 46 const ssize_t r = HANDLE_EINTR(sendmsg(fd, &msg, 0)); |
| 47 const bool ret = static_cast<ssize_t>(length) == r; | 47 const bool ret = static_cast<ssize_t>(length) == r; |
| 48 delete[] control_buffer; | 48 delete[] control_buffer; |
| 49 return ret; | 49 return ret; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // static | 52 // static |
| 53 ssize_t UnixDomainSocket::RecvMsg(int fd, | 53 ssize_t UnixDomainSocket::RecvMsg(int fd, |
| 54 void* buf, | 54 void* buf, |
| 55 size_t length, | 55 size_t length, |
| 56 std::vector<int>* fds) { | 56 std::vector<int>* fds) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |