| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include <errno.h> // NOLINT | 8 #include <errno.h> // NOLINT |
| 9 #include <stdio.h> // NOLINT | 9 #include <stdio.h> // NOLINT |
| 10 #include <stdlib.h> // NOLINT | 10 #include <stdlib.h> // NOLINT |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 if (TEMP_FAILURE_RETRY( | 317 if (TEMP_FAILURE_RETRY( |
| 318 bind(fd, | 318 bind(fd, |
| 319 &addr.addr, | 319 &addr.addr, |
| 320 SocketAddress::GetAddrLength(&addr))) < 0) { | 320 SocketAddress::GetAddrLength(&addr))) < 0) { |
| 321 VOID_TEMP_FAILURE_RETRY(close(fd)); | 321 VOID_TEMP_FAILURE_RETRY(close(fd)); |
| 322 return -1; | 322 return -1; |
| 323 } | 323 } |
| 324 | 324 |
| 325 // Test for invalid socket port 65535 (some browsers disallow it). | 325 // Test for invalid socket port 65535 (some browsers disallow it). |
| 326 if (port == 0 && Socket::GetPort(fd) == 65535) { | 326 if (port == 0 && Socket::GetPort(fd) == 65535) { |
| 327 // Don't close fd until we have created new. By doing that we ensure another | 327 // Don't close the socket until we have created a new socket, ensuring |
| 328 // port. | 328 // that we do not get the bad port number again. |
| 329 intptr_t new_fd = CreateBindListen(addr, 0, backlog, v6_only); | 329 intptr_t new_fd = CreateBindListen(addr, 0, backlog, v6_only); |
| 330 int err = errno; | 330 int err = errno; |
| 331 VOID_TEMP_FAILURE_RETRY(close(fd)); | 331 VOID_TEMP_FAILURE_RETRY(close(fd)); |
| 332 errno = err; | 332 errno = err; |
| 333 return new_fd; | 333 return new_fd; |
| 334 } | 334 } |
| 335 | 335 |
| 336 if (TEMP_FAILURE_RETRY(listen(fd, backlog > 0 ? backlog : SOMAXCONN)) != 0) { | 336 if (TEMP_FAILURE_RETRY(listen(fd, backlog > 0 ? backlog : SOMAXCONN)) != 0) { |
| 337 VOID_TEMP_FAILURE_RETRY(close(fd)); | 337 VOID_TEMP_FAILURE_RETRY(close(fd)); |
| 338 return -1; | 338 return -1; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 IPPROTO_TCP, | 391 IPPROTO_TCP, |
| 392 TCP_NODELAY, | 392 TCP_NODELAY, |
| 393 reinterpret_cast<char *>(&on), | 393 reinterpret_cast<char *>(&on), |
| 394 sizeof(on))) == 0; | 394 sizeof(on))) == 0; |
| 395 } | 395 } |
| 396 | 396 |
| 397 } // namespace bin | 397 } // namespace bin |
| 398 } // namespace dart | 398 } // namespace dart |
| 399 | 399 |
| 400 #endif // defined(TARGET_OS_MACOS) | 400 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |