summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_posix.h
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-08 21:22:24 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-08 21:22:24 +0000
commite40f5a0b82006e487aada4559c2704dc1211f041 (patch)
tree80ee2d5af5cd4e30ae16216ffe77c4186f904066 /ipc/ipc_channel_posix.h
parente04975a7279393c8ba849cac4d96b6583bf024d5 (diff)
downloadchromium_src-e40f5a0b82006e487aada4559c2704dc1211f041.zip
chromium_src-e40f5a0b82006e487aada4559c2704dc1211f041.tar.gz
chromium_src-e40f5a0b82006e487aada4559c2704dc1211f041.tar.bz2
Define IPC_USES_READWRITE
Simplify debugging some Linux issues on the Mac by allowing Mac users to compile with IPC_USES_READWRITE set to 1 and pass file descriptors in the same manner that Linux does by default. Previously it was all controlled by #if !defined OS_MACOSX. BUG=none TEST=build Review URL: http://codereview.chromium.org/5563005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68636 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_posix.h')
-rw-r--r--ipc/ipc_channel_posix.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/ipc/ipc_channel_posix.h b/ipc/ipc_channel_posix.h
index 77a993e..4ff3de1 100644
--- a/ipc/ipc_channel_posix.h
+++ b/ipc/ipc_channel_posix.h
@@ -17,6 +17,27 @@
#include "base/message_loop.h"
#include "ipc/file_descriptor_set_posix.h"
+#if !defined(OS_MACOSX)
+// On Linux, the seccomp sandbox makes it very expensive to call
+// recvmsg() and sendmsg(). The restriction on calling read() and write(), which
+// are cheap, is that we can't pass file descriptors over them.
+//
+// As we cannot anticipate when the sender will provide us with file
+// descriptors, 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 descriptors.
+// Mac can also run in IPC_USES_READWRITE mode if necessary, but at this time
+// doesn't take a performance hit from recvmsg and sendmsg, so it doesn't
+// make sense to waste resources on having the separate dedicated socketpair.
+// It is however useful for debugging between Linux and Mac to be able to turn
+// this switch 'on' on the Mac as well.
+
+// The HELLO message from the client to the server is always sent using
+// sendmsg because it will contain the file descriptor that the server
+// needs to send file descriptors in later messages.
+#define IPC_USES_READWRITE 1
+#endif
+
namespace IPC {
// An implementation of ChannelImpl for POSIX systems that works via
@@ -73,7 +94,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
// pipe_ that is passed to the client.
int client_pipe_;
-#if !defined(OS_MACOSX)
+#if defined(IPC_USES_READWRITE)
// Linux/BSD use a dedicated socketpair() for passing file descriptors.
int fd_pipe_;
int remote_fd_pipe_;