OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/socket.h> | 10 #include <sys/socket.h> |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 645 |
646 if (!AcceptConnection()) { | 646 if (!AcceptConnection()) { |
647 NOTREACHED() << "AcceptConnection should not fail on server"; | 647 NOTREACHED() << "AcceptConnection should not fail on server"; |
648 } | 648 } |
649 waiting_connect_ = false; | 649 waiting_connect_ = false; |
650 #endif | 650 #endif |
651 } else if (fd == pipe_) { | 651 } else if (fd == pipe_) { |
652 if (waiting_connect_ && (mode_ & MODE_SERVER_FLAG)) { | 652 if (waiting_connect_ && (mode_ & MODE_SERVER_FLAG)) { |
653 waiting_connect_ = false; | 653 waiting_connect_ = false; |
654 } | 654 } |
655 if (!ProcessIncomingMessages()) { | 655 if (ProcessIncomingMessages() == DISPATCH_ERROR) { |
656 // ClosePipeOnError may delete this object, so we mustn't call | 656 // ClosePipeOnError may delete this object, so we mustn't call |
657 // ProcessOutgoingMessages. | 657 // ProcessOutgoingMessages. |
658 ClosePipeOnError(); | 658 ClosePipeOnError(); |
659 return; | 659 return; |
660 } | 660 } |
661 } else { | 661 } else { |
662 NOTREACHED() << "Unknown pipe " << fd; | 662 NOTREACHED() << "Unknown pipe " << fd; |
663 } | 663 } |
664 | 664 |
665 // If we're a server and handshaking, then we want to make sure that we | 665 // If we're a server and handshaking, then we want to make sure that we |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 DCHECK(*bytes_read); | 792 DCHECK(*bytes_read); |
793 | 793 |
794 CloseClientFileDescriptor(); | 794 CloseClientFileDescriptor(); |
795 | 795 |
796 // Read any file descriptors from the message. | 796 // Read any file descriptors from the message. |
797 if (!ExtractFileDescriptorsFromMsghdr(&msg)) | 797 if (!ExtractFileDescriptorsFromMsghdr(&msg)) |
798 return READ_FAILED; | 798 return READ_FAILED; |
799 return READ_SUCCEEDED; | 799 return READ_SUCCEEDED; |
800 } | 800 } |
801 | 801 |
| 802 bool ChannelPosix::ShouldDispatchInputMessage(Message* msg) { |
| 803 return true; |
| 804 } |
| 805 |
802 // On Posix, we need to fix up the file descriptors before the input message | 806 // On Posix, we need to fix up the file descriptors before the input message |
803 // is dispatched. | 807 // is dispatched. |
804 // | 808 // |
805 // This will read from the input_fds_ (READWRITE mode only) and read more | 809 // This will read from the input_fds_ (READWRITE mode only) and read more |
806 // handles from the FD pipe if necessary. | 810 // handles from the FD pipe if necessary. |
807 bool ChannelPosix::WillDispatchInputMessage(Message* msg) { | 811 bool ChannelPosix::GetNonBrokeredAttachments(Message* msg) { |
808 uint16 header_fds = msg->header()->num_fds; | 812 uint16 header_fds = msg->header()->num_fds; |
809 if (!header_fds) | 813 if (!header_fds) |
810 return true; // Nothing to do. | 814 return true; // Nothing to do. |
811 | 815 |
812 // The message has file descriptors. | 816 // The message has file descriptors. |
813 const char* error = NULL; | 817 const char* error = NULL; |
814 if (header_fds > input_fds_.size()) { | 818 if (header_fds > input_fds_.size()) { |
815 // The message has been completely received, but we didn't get | 819 // The message has been completely received, but we didn't get |
816 // enough file descriptors. | 820 // enough file descriptors. |
817 error = "Message needs unreceived descriptors"; | 821 error = "Message needs unreceived descriptors"; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 } | 1033 } |
1030 | 1034 |
1031 #if defined(OS_LINUX) | 1035 #if defined(OS_LINUX) |
1032 // static | 1036 // static |
1033 void Channel::SetGlobalPid(int pid) { | 1037 void Channel::SetGlobalPid(int pid) { |
1034 ChannelPosix::SetGlobalPid(pid); | 1038 ChannelPosix::SetGlobalPid(pid); |
1035 } | 1039 } |
1036 #endif // OS_LINUX | 1040 #endif // OS_LINUX |
1037 | 1041 |
1038 } // namespace IPC | 1042 } // namespace IPC |
OLD | NEW |