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

Side by Side Diff: ipc/ipc_channel_posix.h

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef IPC_IPC_CHANNEL_POSIX_H_ 5 #ifndef IPC_IPC_CHANNEL_POSIX_H_
6 #define IPC_IPC_CHANNEL_POSIX_H_ 6 #define IPC_IPC_CHANNEL_POSIX_H_
7 #pragma once 7 #pragma once
8 8
9 #include "ipc/ipc_channel.h" 9 #include "ipc/ipc_channel.h"
10 10
11 #include <sys/socket.h> // for CMSG macros 11 #include <sys/socket.h> // for CMSG macros
12 12
13 #include <queue> 13 #include <queue>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "ipc/file_descriptor_set_posix.h" 18 #include "ipc/file_descriptor_set_posix.h"
19 19
20 #if !defined(OS_MACOSX)
21 // On Linux, the seccomp sandbox makes it very expensive to call
22 // recvmsg() and sendmsg(). The restriction on calling read() and write(), which
23 // are cheap, is that we can't pass file descriptors over them.
24 //
25 // As we cannot anticipate when the sender will provide us with file
26 // descriptors, we have to make the decision about whether we call read() or
27 // recvmsg() before we actually make the call. The easiest option is to
28 // create a dedicated socketpair() for exchanging file descriptors.
29 // Mac can also run in IPC_USES_READWRITE mode if necessary, but at this time
30 // doesn't take a performance hit from recvmsg and sendmsg, so it doesn't
31 // make sense to waste resources on having the separate dedicated socketpair.
32 // It is however useful for debugging between Linux and Mac to be able to turn
33 // this switch 'on' on the Mac as well.
34
35 // The HELLO message from the client to the server is always sent using
36 // sendmsg because it will contain the file descriptor that the server
37 // needs to send file descriptors in later messages.
38 #define IPC_USES_READWRITE 1
39 #endif
40
20 namespace IPC { 41 namespace IPC {
21 42
22 // Store that channel name |name| is available via socket |socket|. 43 // Store that channel name |name| is available via socket |socket|.
23 // Used when the channel has been precreated by another process on 44 // Used when the channel has been precreated by another process on
24 // our behalf and they've just shipped us the socket. 45 // our behalf and they've just shipped us the socket.
25 void AddChannelSocket(const std::string& name, int socket); 46 void AddChannelSocket(const std::string& name, int socket);
26 47
27 // Remove the channel name mapping, and close the corresponding socket. 48 // Remove the channel name mapping, and close the corresponding socket.
28 void RemoveAndCloseChannelSocket(const std::string& name); 49 void RemoveAndCloseChannelSocket(const std::string& name);
29 50
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // unused otherwise. 101 // unused otherwise.
81 int server_listen_pipe_; 102 int server_listen_pipe_;
82 103
83 // The pipe used for communication. 104 // The pipe used for communication.
84 int pipe_; 105 int pipe_;
85 106
86 // For a server, the client end of our socketpair() -- the other end of our 107 // For a server, the client end of our socketpair() -- the other end of our
87 // pipe_ that is passed to the client. 108 // pipe_ that is passed to the client.
88 int client_pipe_; 109 int client_pipe_;
89 110
90 #if !defined(OS_MACOSX) 111 #if defined(IPC_USES_READWRITE)
91 // Linux/BSD use a dedicated socketpair() for passing file descriptors. 112 // Linux/BSD use a dedicated socketpair() for passing file descriptors.
92 int fd_pipe_; 113 int fd_pipe_;
93 int remote_fd_pipe_; 114 int remote_fd_pipe_;
94 #endif 115 #endif
95 116
96 // The "name" of our pipe. On Windows this is the global identifier for 117 // The "name" of our pipe. On Windows this is the global identifier for
97 // the pipe. On POSIX it's used as a key in a local map of file descriptors. 118 // the pipe. On POSIX it's used as a key in a local map of file descriptors.
98 std::string pipe_name_; 119 std::string pipe_name_;
99 120
100 Listener* listener_; 121 Listener* listener_;
(...skipping 30 matching lines...) Expand all
131 bool waiting_connect_; 152 bool waiting_connect_;
132 153
133 ScopedRunnableMethodFactory<ChannelImpl> factory_; 154 ScopedRunnableMethodFactory<ChannelImpl> factory_;
134 155
135 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); 156 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
136 }; 157 };
137 158
138 } // namespace IPC 159 } // namespace IPC
139 160
140 #endif // IPC_IPC_CHANNEL_POSIX_H_ 161 #endif // IPC_IPC_CHANNEL_POSIX_H_
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698