| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 int optval = 1; | 316 int optval = 1; |
| 317 VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS( | 317 VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS( |
| 318 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); | 318 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); |
| 319 } | 319 } |
| 320 | 320 |
| 321 SocketAddress::SetAddrPort(addr, port); | 321 SocketAddress::SetAddrPort(addr, port); |
| 322 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS( | 322 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS( |
| 323 bind(fd, | 323 bind(fd, |
| 324 &addr->addr, | 324 &addr->addr, |
| 325 SocketAddress::GetAddrLength(addr))) < 0) { | 325 SocketAddress::GetAddrLength(addr))) < 0) { |
| 326 TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fd)); | 326 VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fd)); |
| 327 return -1; | 327 return -1; |
| 328 } | 328 } |
| 329 return fd; | 329 return fd; |
| 330 } | 330 } |
| 331 | 331 |
| 332 | 332 |
| 333 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { | 333 static bool ShouldIncludeIfaAddrs(struct ifaddrs* ifa, int lookup_family) { |
| 334 if (ifa->ifa_addr == NULL) { | 334 if (ifa->ifa_addr == NULL) { |
| 335 // OpenVPN's virtual device tun0. | 335 // OpenVPN's virtual device tun0. |
| 336 return false; | 336 return false; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 intptr_t port, | 385 intptr_t port, |
| 386 intptr_t backlog, | 386 intptr_t backlog, |
| 387 bool v6_only) { | 387 bool v6_only) { |
| 388 intptr_t fd; | 388 intptr_t fd; |
| 389 | 389 |
| 390 fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(socket( | 390 fd = TEMP_FAILURE_RETRY_BLOCK_SIGNALS(socket( |
| 391 addr.ss.ss_family, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)); | 391 addr.ss.ss_family, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)); |
| 392 if (fd < 0) return -1; | 392 if (fd < 0) return -1; |
| 393 | 393 |
| 394 int optval = 1; | 394 int optval = 1; |
| 395 TEMP_FAILURE_RETRY_BLOCK_SIGNALS( | 395 VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS( |
| 396 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); | 396 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval))); |
| 397 | 397 |
| 398 if (addr.ss.ss_family == AF_INET6) { | 398 if (addr.ss.ss_family == AF_INET6) { |
| 399 optval = v6_only ? 1 : 0; | 399 optval = v6_only ? 1 : 0; |
| 400 TEMP_FAILURE_RETRY_BLOCK_SIGNALS( | 400 VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS( |
| 401 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval))); | 401 setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval))); |
| 402 } | 402 } |
| 403 | 403 |
| 404 SocketAddress::SetAddrPort(&addr, port); | 404 SocketAddress::SetAddrPort(&addr, port); |
| 405 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS( | 405 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS( |
| 406 bind(fd, | 406 bind(fd, |
| 407 &addr.addr, | 407 &addr.addr, |
| 408 SocketAddress::GetAddrLength(&addr))) < 0) { | 408 SocketAddress::GetAddrLength(&addr))) < 0) { |
| 409 VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fd)); | 409 VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(close(fd)); |
| 410 return -1; | 410 return -1; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 mreq.gr_interface = interfaceIndex; | 601 mreq.gr_interface = interfaceIndex; |
| 602 memmove(&mreq.gr_group, &addr->ss, SocketAddress::GetAddrLength(addr)); | 602 memmove(&mreq.gr_group, &addr->ss, SocketAddress::GetAddrLength(addr)); |
| 603 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt( | 603 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt( |
| 604 fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; | 604 fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; |
| 605 } | 605 } |
| 606 | 606 |
| 607 } // namespace bin | 607 } // namespace bin |
| 608 } // namespace dart | 608 } // namespace dart |
| 609 | 609 |
| 610 #endif // defined(TARGET_OS_LINUX) | 610 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |