Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/unix_domain_socket_util.h" | 5 #include "ipc/unix_domain_socket_util.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| 11 #include <sys/un.h> | 11 #include <sys/un.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 | 13 |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/files/scoped_file.h" | 16 #include "base/files/scoped_file.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/posix/eintr_wrapper.h" | 18 #include "base/posix/eintr_wrapper.h" |
| 19 | 19 |
| 20 namespace IPC { | 20 namespace IPC { |
| 21 | 21 |
| 22 // Verify that kMaxSocketNameLength is a decent size. | 22 // Verify that kMaxSocketNameLength is a decent size. |
| 23 COMPILE_ASSERT(sizeof(((sockaddr_un*)0)->sun_path) >= kMaxSocketNameLength, | 23 static_assert(sizeof(((sockaddr_un*)0)->sun_path) >= kMaxSocketNameLength, |
| 24 BAD_SUN_PATH_LENGTH); | 24 "BAD SUN PATH LENGTH"); |
|
dmichael (off chromium)
2015/01/20 16:44:10
How about:
"sun_path is too long."
anujsharma
2015/01/21 03:11:51
Done.
| |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Returns fd (>= 0) on success, -1 on failure. If successful, fills in | 28 // Returns fd (>= 0) on success, -1 on failure. If successful, fills in |
| 29 // |unix_addr| with the appropriate data for the socket, and sets | 29 // |unix_addr| with the appropriate data for the socket, and sets |
| 30 // |unix_addr_len| to the length of the data therein. | 30 // |unix_addr_len| to the length of the data therein. |
| 31 int MakeUnixAddrForPath(const std::string& socket_name, | 31 int MakeUnixAddrForPath(const std::string& socket_name, |
| 32 struct sockaddr_un* unix_addr, | 32 struct sockaddr_un* unix_addr, |
| 33 size_t* unix_addr_len) { | 33 size_t* unix_addr_len) { |
| 34 DCHECK(unix_addr); | 34 DCHECK(unix_addr); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 // It's safe to keep listening on |server_listen_fd| even if the attempt to | 192 // It's safe to keep listening on |server_listen_fd| even if the attempt to |
| 193 // set O_NONBLOCK failed on the client fd. | 193 // set O_NONBLOCK failed on the client fd. |
| 194 return true; | 194 return true; |
| 195 } | 195 } |
| 196 | 196 |
| 197 *server_socket = accept_fd.release(); | 197 *server_socket = accept_fd.release(); |
| 198 return true; | 198 return true; |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace IPC | 201 } // namespace IPC |
| OLD | NEW |