| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 "chrome/common/ipc_channel_posix.h" | 5 #include "chrome/common/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> |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 msgh.msg_controllen = cmsg->cmsg_len; | 600 msgh.msg_controllen = cmsg->cmsg_len; |
| 601 | 601 |
| 602 msg->header()->num_fds = num_fds; | 602 msg->header()->num_fds = num_fds; |
| 603 } | 603 } |
| 604 | 604 |
| 605 ssize_t bytes_written = HANDLE_EINTR(sendmsg(pipe_, &msgh, MSG_DONTWAIT)); | 605 ssize_t bytes_written = HANDLE_EINTR(sendmsg(pipe_, &msgh, MSG_DONTWAIT)); |
| 606 if (bytes_written > 0) | 606 if (bytes_written > 0) |
| 607 msg->file_descriptor_set()->CommitAll(); | 607 msg->file_descriptor_set()->CommitAll(); |
| 608 | 608 |
| 609 if (bytes_written < 0 && errno != EAGAIN) { | 609 if (bytes_written < 0 && errno != EAGAIN) { |
| 610 #if defined(OS_MACOSX) |
| 611 // On OSX writing to a pipe with no listener returns EPERM. |
| 612 if (errno == EPERM) { |
| 613 Close(); |
| 614 return false; |
| 615 } |
| 616 #endif // OS_MACOSX |
| 610 LOG(ERROR) << "pipe error: " << strerror(errno); | 617 LOG(ERROR) << "pipe error: " << strerror(errno); |
| 611 return false; | 618 return false; |
| 612 } | 619 } |
| 613 | 620 |
| 614 if (static_cast<size_t>(bytes_written) != amt_to_write) { | 621 if (static_cast<size_t>(bytes_written) != amt_to_write) { |
| 615 if (bytes_written > 0) { | 622 if (bytes_written > 0) { |
| 616 // If write() fails with EAGAIN then bytes_written will be -1. | 623 // If write() fails with EAGAIN then bytes_written will be -1. |
| 617 message_send_bytes_written_ += bytes_written; | 624 message_send_bytes_written_ += bytes_written; |
| 618 } | 625 } |
| 619 | 626 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 | 801 |
| 795 bool Channel::Send(Message* message) { | 802 bool Channel::Send(Message* message) { |
| 796 return channel_impl_->Send(message); | 803 return channel_impl_->Send(message); |
| 797 } | 804 } |
| 798 | 805 |
| 799 void Channel::GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const { | 806 void Channel::GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const { |
| 800 return channel_impl_->GetClientFileDescriptorMapping(src_fd, dest_fd); | 807 return channel_impl_->GetClientFileDescriptorMapping(src_fd, dest_fd); |
| 801 } | 808 } |
| 802 | 809 |
| 803 } // namespace IPC | 810 } // namespace IPC |
| OLD | NEW |