OLD | NEW |
---|---|
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 #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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 int dup_fd = dup(fd); | 128 int dup_fd = dup(fd); |
129 if (dup_fd < 0) | 129 if (dup_fd < 0) |
130 PLOG(FATAL) << "dup(" << fd << ")"; | 130 PLOG(FATAL) << "dup(" << fd << ")"; |
131 return dup_fd; | 131 return dup_fd; |
132 } | 132 } |
133 | 133 |
134 return fd; | 134 return fd; |
135 } | 135 } |
136 | 136 |
137 //------------------------------------------------------------------------------ | 137 //------------------------------------------------------------------------------ |
138 sockaddr_un sizecheck; | 138 const size_t kMaxPipeNameLength = sizeof(((sockaddr_un*)0)->sun_path); |
Evan Martin
2010/09/22 00:03:47
Is this really the best way to accomplish this? T
Nico
2010/09/22 00:06:25
I asked on cfe-dev, and this is what The Chris Lat
| |
139 const size_t kMaxPipeNameLength = sizeof(sizecheck.sun_path); | |
140 | 139 |
141 // Creates a Fifo with the specified name ready to listen on. | 140 // Creates a Fifo with the specified name ready to listen on. |
142 bool CreateServerFifo(const std::string& pipe_name, int* server_listen_fd) { | 141 bool CreateServerFifo(const std::string& pipe_name, int* server_listen_fd) { |
143 DCHECK(server_listen_fd); | 142 DCHECK(server_listen_fd); |
144 DCHECK_GT(pipe_name.length(), 0u); | 143 DCHECK_GT(pipe_name.length(), 0u); |
145 DCHECK_LT(pipe_name.length(), kMaxPipeNameLength); | 144 DCHECK_LT(pipe_name.length(), kMaxPipeNameLength); |
146 | 145 |
147 if (pipe_name.length() == 0 || pipe_name.length() >= kMaxPipeNameLength) { | 146 if (pipe_name.length() == 0 || pipe_name.length() >= kMaxPipeNameLength) { |
148 return false; | 147 return false; |
149 } | 148 } |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 | 1083 |
1085 bool Channel::Send(Message* message) { | 1084 bool Channel::Send(Message* message) { |
1086 return channel_impl_->Send(message); | 1085 return channel_impl_->Send(message); |
1087 } | 1086 } |
1088 | 1087 |
1089 int Channel::GetClientFileDescriptor() const { | 1088 int Channel::GetClientFileDescriptor() const { |
1090 return channel_impl_->GetClientFileDescriptor(); | 1089 return channel_impl_->GetClientFileDescriptor(); |
1091 } | 1090 } |
1092 | 1091 |
1093 } // namespace IPC | 1092 } // namespace IPC |
OLD | NEW |