| 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 "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> |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 if (bytes_read < 0) { | 440 if (bytes_read < 0) { |
| 441 if (errno == EAGAIN) { | 441 if (errno == EAGAIN) { |
| 442 return true; | 442 return true; |
| 443 #if defined(OS_MACOSX) | 443 #if defined(OS_MACOSX) |
| 444 } else if (errno == EPERM) { | 444 } else if (errno == EPERM) { |
| 445 // On OSX, reading from a pipe with no listener returns EPERM | 445 // On OSX, reading from a pipe with no listener returns EPERM |
| 446 // treat this as a special case to prevent spurious error messages | 446 // treat this as a special case to prevent spurious error messages |
| 447 // to the console. | 447 // to the console. |
| 448 return false; | 448 return false; |
| 449 #endif // defined(OS_MACOSX) | 449 #endif // defined(OS_MACOSX) |
| 450 } else if (errno == ECONNRESET) { | 450 } else if (errno == ECONNRESET || errno == EPIPE) { |
| 451 return false; | 451 return false; |
| 452 } else { | 452 } else { |
| 453 PLOG(ERROR) << "pipe error (" << pipe_ << ")"; | 453 PLOG(ERROR) << "pipe error (" << pipe_ << ")"; |
| 454 return false; | 454 return false; |
| 455 } | 455 } |
| 456 } else if (bytes_read == 0) { | 456 } else if (bytes_read == 0) { |
| 457 // The pipe has closed... | 457 // The pipe has closed... |
| 458 return false; | 458 return false; |
| 459 } | 459 } |
| 460 } | 460 } |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 msg->file_descriptor_set()->CommitAll(); | 805 msg->file_descriptor_set()->CommitAll(); |
| 806 | 806 |
| 807 if (bytes_written < 0 && errno != EAGAIN) { | 807 if (bytes_written < 0 && errno != EAGAIN) { |
| 808 #if defined(OS_MACOSX) | 808 #if defined(OS_MACOSX) |
| 809 // On OSX writing to a pipe with no listener returns EPERM. | 809 // On OSX writing to a pipe with no listener returns EPERM. |
| 810 if (errno == EPERM) { | 810 if (errno == EPERM) { |
| 811 Close(); | 811 Close(); |
| 812 return false; | 812 return false; |
| 813 } | 813 } |
| 814 #endif // OS_MACOSX | 814 #endif // OS_MACOSX |
| 815 if (errno == EPIPE) { |
| 816 Close(); |
| 817 return false; |
| 818 } |
| 815 PLOG(ERROR) << "pipe error on " << fd_written; | 819 PLOG(ERROR) << "pipe error on " << fd_written; |
| 816 return false; | 820 return false; |
| 817 } | 821 } |
| 818 | 822 |
| 819 if (static_cast<size_t>(bytes_written) != amt_to_write) { | 823 if (static_cast<size_t>(bytes_written) != amt_to_write) { |
| 820 if (bytes_written > 0) { | 824 if (bytes_written > 0) { |
| 821 // If write() fails with EAGAIN then bytes_written will be -1. | 825 // If write() fails with EAGAIN then bytes_written will be -1. |
| 822 message_send_bytes_written_ += bytes_written; | 826 message_send_bytes_written_ += bytes_written; |
| 823 } | 827 } |
| 824 | 828 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 | 1010 |
| 1007 bool Channel::Send(Message* message) { | 1011 bool Channel::Send(Message* message) { |
| 1008 return channel_impl_->Send(message); | 1012 return channel_impl_->Send(message); |
| 1009 } | 1013 } |
| 1010 | 1014 |
| 1011 int Channel::GetClientFileDescriptor() const { | 1015 int Channel::GetClientFileDescriptor() const { |
| 1012 return channel_impl_->GetClientFileDescriptor(); | 1016 return channel_impl_->GetClientFileDescriptor(); |
| 1013 } | 1017 } |
| 1014 | 1018 |
| 1015 } // namespace IPC | 1019 } // namespace IPC |
| OLD | NEW |