Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Unified Diff: ipc/ipc_channel_posix.cc

Issue 5563005: Define IPC_USES_READWRITE (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_channel_posix.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_posix.cc
diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc
index bbf137432943d7abfe487f8dacf96828a31823ee..4a71f424eac123aa898ce329069813da0bf1f3b9 100644
--- a/ipc/ipc_channel_posix.cc
+++ b/ipc/ipc_channel_posix.cc
@@ -285,7 +285,7 @@ Channel::ChannelImpl::ChannelImpl(const std::string& channel_id, Mode mode,
server_listen_pipe_(-1),
pipe_(-1),
client_pipe_(-1),
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
fd_pipe_(-1),
remote_fd_pipe_(-1),
#endif
@@ -407,16 +407,10 @@ bool Channel::ChannelImpl::CreatePipe(const std::string& channel_id,
scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE,
HELLO_MESSAGE_TYPE,
IPC::Message::PRIORITY_NORMAL));
- #if !defined(OS_MACOSX)
+ #if defined(IPC_USES_READWRITE)
if (!uses_fifo_) {
- // On Linux, the seccomp sandbox makes it very expensive to call
- // recvmsg() and sendmsg(). Often, we are perfectly OK with resorting to
- // read() and write(), which are cheap.
- //
- // As we cannot anticipate, when the sender will provide us with file
- // handles, we have to make the decision about whether we call read() or
- // recvmsg() before we actually make the call. The easiest option is to
- // create a dedicated socketpair() for exchanging file handles.
+ // Create a dedicated socketpair() for exchanging file descriptors.
+ // See comments for IPC_USES_READWRITE for details.
if (mode == MODE_SERVER) {
fd_pipe_ = -1;
} else if (remote_fd_pipe_ == -1) {
@@ -483,7 +477,7 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() {
// Read from pipe.
// recvmsg() returns 0 if the connection has closed or EAGAIN if no data
// is waiting on the pipe.
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
if (fd_pipe_ >= 0) {
bytes_read = HANDLE_EINTR(read(pipe_, input_buf_,
Channel::kReadBufferSize));
@@ -616,7 +610,7 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() {
if (m.header()->num_fds > num_fds - fds_i) {
// the message has been completely received, but we didn't get
// enough file descriptors.
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
if (!uses_fifo_) {
char dummy;
struct iovec fd_pipe_iov = { &dummy, 1 };
@@ -706,7 +700,7 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() {
if (!m.ReadInt(&iter, &pid)) {
NOTREACHED();
}
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
if (mode_ == MODE_SERVER && !uses_fifo_) {
// On non-Mac, the Hello message from the client to the server
// also contains the fd_pipe_, which will be used for all
@@ -769,7 +763,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
while (!output_queue_.empty()) {
Message* msg = output_queue_.front();
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
scoped_ptr<Message> hello;
if (remote_fd_pipe_ != -1 &&
msg->routing_id() == MSG_ROUTING_NONE &&
@@ -839,7 +833,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
// num_fds < MAX_DESCRIPTORS_PER_MESSAGE so no danger of overflow.
msg->header()->num_fds = static_cast<uint16>(num_fds);
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
if (!uses_fifo_ &&
(msg->routing_id() != MSG_ROUTING_NONE ||
msg->type() != HELLO_MESSAGE_TYPE)) {
@@ -861,7 +855,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
if (bytes_written == 1) {
fd_written = pipe_;
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
if (mode_ != MODE_SERVER && !uses_fifo_ &&
msg->routing_id() == MSG_ROUTING_NONE &&
msg->type() == HELLO_MESSAGE_TYPE) {
@@ -1030,7 +1024,7 @@ void Channel::ChannelImpl::Close() {
PipeMap::GetInstance()->RemoveAndClose(pipe_name_);
client_pipe_ = -1;
}
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
if (fd_pipe_ != -1) {
if (HANDLE_EINTR(close(fd_pipe_)) < 0)
PLOG(ERROR) << "close";
« no previous file with comments | « ipc/ipc_channel_posix.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698