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

Side by Side Diff: ipc/ipc_channel_posix.h

Issue 25325002: workaround for mac kernel bug (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor bugfix Created 7 years, 2 months 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 | « ipc/ipc_channel_nacl.cc ('k') | 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) 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 #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 7
8 #include "ipc/ipc_channel.h" 8 #include "ipc/ipc_channel.h"
9 9
10 #include <sys/socket.h> // for CMSG macros 10 #include <sys/socket.h> // for CMSG macros
11 11
12 #include <queue> 12 #include <queue>
13 #include <set>
13 #include <string> 14 #include <string>
14 #include <vector> 15 #include <vector>
15 16
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "base/process/process.h" 18 #include "base/process/process.h"
18 #include "ipc/file_descriptor_set_posix.h" 19 #include "ipc/file_descriptor_set_posix.h"
19 #include "ipc/ipc_channel_reader.h" 20 #include "ipc/ipc_channel_reader.h"
20 21
21 #if !defined(OS_MACOSX) 22 #if !defined(OS_MACOSX)
22 // On Linux, the seccomp sandbox makes it very expensive to call 23 // On Linux, the seccomp sandbox makes it very expensive to call
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 private: 75 private:
75 bool CreatePipe(const IPC::ChannelHandle& channel_handle); 76 bool CreatePipe(const IPC::ChannelHandle& channel_handle);
76 77
77 bool ProcessOutgoingMessages(); 78 bool ProcessOutgoingMessages();
78 79
79 bool AcceptConnection(); 80 bool AcceptConnection();
80 void ClosePipeOnError(); 81 void ClosePipeOnError();
81 int GetHelloMessageProcId(); 82 int GetHelloMessageProcId();
82 void QueueHelloMessage(); 83 void QueueHelloMessage();
84 void CloseFileDescriptors(Message* msg);
85 void QueueCloseFDMessage(int fd, int hops);
83 86
84 // ChannelReader implementation. 87 // ChannelReader implementation.
85 virtual ReadState ReadData(char* buffer, 88 virtual ReadState ReadData(char* buffer,
86 int buffer_len, 89 int buffer_len,
87 int* bytes_read) OVERRIDE; 90 int* bytes_read) OVERRIDE;
88 virtual bool WillDispatchInputMessage(Message* msg) OVERRIDE; 91 virtual bool WillDispatchInputMessage(Message* msg) OVERRIDE;
89 virtual bool DidEmptyInputBuffers() OVERRIDE; 92 virtual bool DidEmptyInputBuffers() OVERRIDE;
90 virtual void HandleHelloMessage(const Message& msg) OVERRIDE; 93 virtual void HandleInternalMessage(const Message& msg) OVERRIDE;
91 94
92 #if defined(IPC_USES_READWRITE) 95 #if defined(IPC_USES_READWRITE)
93 // Reads the next message from the fd_pipe_ and appends them to the 96 // Reads the next message from the fd_pipe_ and appends them to the
94 // input_fds_ queue. Returns false if there was a message receiving error. 97 // input_fds_ queue. Returns false if there was a message receiving error.
95 // True means there was a message and it was processed properly, or there was 98 // True means there was a message and it was processed properly, or there was
96 // no messages. 99 // no messages.
97 bool ReadFileDescriptorsFromFDPipe(); 100 bool ReadFileDescriptorsFromFDPipe();
98 #endif 101 #endif
99 102
100 // Finds the set of file descriptors in the given message. On success, 103 // Finds the set of file descriptors in the given message. On success,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 char input_cmsg_buf_[kMaxReadFDBuffer]; 180 char input_cmsg_buf_[kMaxReadFDBuffer];
178 181
179 // File descriptors extracted from messages coming off of the channel. The 182 // File descriptors extracted from messages coming off of the channel. The
180 // handles may span messages and come off different channels from the message 183 // handles may span messages and come off different channels from the message
181 // data (in the case of READWRITE), and are processed in FIFO here. 184 // data (in the case of READWRITE), and are processed in FIFO here.
182 // NOTE: The implementation assumes underlying storage here is contiguous, so 185 // NOTE: The implementation assumes underlying storage here is contiguous, so
183 // don't change to something like std::deque<> without changing the 186 // don't change to something like std::deque<> without changing the
184 // implementation! 187 // implementation!
185 std::vector<int> input_fds_; 188 std::vector<int> input_fds_;
186 189
190 #if defined(OS_MACOSX)
191 // On OSX, sent FDs must not be closed until we get an ack.
192 // Keep track of sent FDs here to make sure the remote is not
193 // trying to bamboozle us.
194 std::set<int> fds_to_close_;
195 #endif
196
187 // True if we are responsible for unlinking the unix domain socket file. 197 // True if we are responsible for unlinking the unix domain socket file.
188 bool must_unlink_; 198 bool must_unlink_;
189 199
190 #if defined(OS_LINUX) 200 #if defined(OS_LINUX)
191 // If non-zero, overrides the process ID sent in the hello message. 201 // If non-zero, overrides the process ID sent in the hello message.
192 static int global_pid_; 202 static int global_pid_;
193 #endif // OS_LINUX 203 #endif // OS_LINUX
194 204
195 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelImpl); 205 DISALLOW_IMPLICIT_CONSTRUCTORS(ChannelImpl);
196 }; 206 };
197 207
198 } // namespace IPC 208 } // namespace IPC
199 209
200 #endif // IPC_IPC_CHANNEL_POSIX_H_ 210 #endif // IPC_IPC_CHANNEL_POSIX_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_nacl.cc ('k') | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698