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

Side by Side Diff: ipc/ipc_channel_posix.cc

Issue 7743001: There are times on the Mac when pipe names of 0 length may occur. Let the caller handle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 | « no previous file | ipc/ipc_channel_posix_unittest.cc » ('j') | ipc/ipc_channel_posix_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/types.h> 10 #include <sys/types.h>
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 //------------------------------------------------------------------------------ 137 //------------------------------------------------------------------------------
138 // Verify that kMaxPipeNameLength is a decent size. 138 // Verify that kMaxPipeNameLength is a decent size.
139 COMPILE_ASSERT(sizeof(((sockaddr_un*)0)->sun_path) >= kMaxPipeNameLength, 139 COMPILE_ASSERT(sizeof(((sockaddr_un*)0)->sun_path) >= kMaxPipeNameLength,
140 BAD_SUN_PATH_LENGTH); 140 BAD_SUN_PATH_LENGTH);
141 141
142 // Creates a unix domain socket bound to the specified name that is listening 142 // Creates a unix domain socket bound to the specified name that is listening
143 // for connections. 143 // for connections.
144 bool CreateServerUnixDomainSocket(const std::string& pipe_name, 144 bool CreateServerUnixDomainSocket(const std::string& pipe_name,
145 int* server_listen_fd) { 145 int* server_listen_fd) {
146 DCHECK(server_listen_fd); 146 DCHECK(server_listen_fd);
147 DCHECK_GT(pipe_name.length(), 0u);
148 DCHECK_LT(pipe_name.length(), kMaxPipeNameLength);
149 147
150 if (pipe_name.length() == 0 || pipe_name.length() >= kMaxPipeNameLength) { 148 if (pipe_name.length() == 0 || pipe_name.length() >= kMaxPipeNameLength) {
149 DLOG(ERROR) << "pipe_name.length() == " << pipe_name.length();
151 return false; 150 return false;
152 } 151 }
153 152
154 // Create socket. 153 // Create socket.
155 int fd = socket(AF_UNIX, SOCK_STREAM, 0); 154 int fd = socket(AF_UNIX, SOCK_STREAM, 0);
156 if (fd < 0) { 155 if (fd < 0) {
157 return false; 156 return false;
158 } 157 }
159 158
160 // Make socket non-blocking 159 // Make socket non-blocking
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 remote_fd_pipe_(-1), 307 remote_fd_pipe_(-1),
309 #endif // IPC_USES_READWRITE 308 #endif // IPC_USES_READWRITE
310 pipe_name_(channel_handle.name), 309 pipe_name_(channel_handle.name),
311 listener_(listener), 310 listener_(listener),
312 must_unlink_(false) { 311 must_unlink_(false) {
313 memset(input_buf_, 0, sizeof(input_buf_)); 312 memset(input_buf_, 0, sizeof(input_buf_));
314 memset(input_cmsg_buf_, 0, sizeof(input_cmsg_buf_)); 313 memset(input_cmsg_buf_, 0, sizeof(input_cmsg_buf_));
315 if (!CreatePipe(channel_handle)) { 314 if (!CreatePipe(channel_handle)) {
316 // The pipe may have been closed already. 315 // The pipe may have been closed already.
317 const char *modestr = (mode_ & MODE_SERVER_FLAG) ? "server" : "client"; 316 const char *modestr = (mode_ & MODE_SERVER_FLAG) ? "server" : "client";
318 // The pipe may have been closed already.
319 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name 317 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name
320 << "\" in " << modestr << " mode"; 318 << "\" in " << modestr << " mode";
321 } 319 }
322 } 320 }
323 321
324 Channel::ChannelImpl::~ChannelImpl() { 322 Channel::ChannelImpl::~ChannelImpl() {
325 Close(); 323 Close();
326 } 324 }
327 325
328 bool SocketPair(int* fd1, int* fd2) { 326 bool SocketPair(int* fd1, int* fd2) {
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 void Channel::ResetToAcceptingConnectionState() { 1205 void Channel::ResetToAcceptingConnectionState() {
1208 channel_impl_->ResetToAcceptingConnectionState(); 1206 channel_impl_->ResetToAcceptingConnectionState();
1209 } 1207 }
1210 1208
1211 // static 1209 // static
1212 bool Channel::IsNamedServerInitialized(const std::string& channel_id) { 1210 bool Channel::IsNamedServerInitialized(const std::string& channel_id) {
1213 return ChannelImpl::IsNamedServerInitialized(channel_id); 1211 return ChannelImpl::IsNamedServerInitialized(channel_id);
1214 } 1212 }
1215 1213
1216 } // namespace IPC 1214 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_channel_posix_unittest.cc » ('j') | ipc/ipc_channel_posix_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698