| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (TEMP_FAILURE_RETRY( | 279 if (TEMP_FAILURE_RETRY( |
| 280 bind(fd, | 280 bind(fd, |
| 281 &addr.addr, | 281 &addr.addr, |
| 282 SocketAddress::GetAddrLength(&addr))) < 0) { | 282 SocketAddress::GetAddrLength(&addr))) < 0) { |
| 283 TEMP_FAILURE_RETRY(close(fd)); | 283 TEMP_FAILURE_RETRY(close(fd)); |
| 284 return -1; | 284 return -1; |
| 285 } | 285 } |
| 286 | 286 |
| 287 // Test for invalid socket port 65535 (some browsers disallow it). | 287 // Test for invalid socket port 65535 (some browsers disallow it). |
| 288 if (port == 0 && Socket::GetPort(fd) == 65535) { | 288 if (port == 0 && Socket::GetPort(fd) == 65535) { |
| 289 // Don't close fd until we have created new. By doing that we ensure another | 289 // Don't close the socket until we have created a new socket, ensuring |
| 290 // port. | 290 // that we do not get the bad port number again. |
| 291 intptr_t new_fd = CreateBindListen(addr, 0, backlog, v6_only); | 291 intptr_t new_fd = CreateBindListen(addr, 0, backlog, v6_only); |
| 292 int err = errno; | 292 int err = errno; |
| 293 VOID_TEMP_FAILURE_RETRY(close(fd)); | 293 VOID_TEMP_FAILURE_RETRY(close(fd)); |
| 294 errno = err; | 294 errno = err; |
| 295 return new_fd; | 295 return new_fd; |
| 296 } | 296 } |
| 297 | 297 |
| 298 if (TEMP_FAILURE_RETRY(listen(fd, backlog > 0 ? backlog : SOMAXCONN)) != 0) { | 298 if (TEMP_FAILURE_RETRY(listen(fd, backlog > 0 ? backlog : SOMAXCONN)) != 0) { |
| 299 TEMP_FAILURE_RETRY(close(fd)); | 299 TEMP_FAILURE_RETRY(close(fd)); |
| 300 return -1; | 300 return -1; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 SOL_TCP, | 363 SOL_TCP, |
| 364 TCP_NODELAY, | 364 TCP_NODELAY, |
| 365 reinterpret_cast<char *>(&on), | 365 reinterpret_cast<char *>(&on), |
| 366 sizeof(on))) == 0; | 366 sizeof(on))) == 0; |
| 367 } | 367 } |
| 368 | 368 |
| 369 } // namespace bin | 369 } // namespace bin |
| 370 } // namespace dart | 370 } // namespace dart |
| 371 | 371 |
| 372 #endif // defined(TARGET_OS_ANDROID) | 372 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |