Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: runtime/bin/socket_macos.cc

Issue 117723003: Fix most UDP issues on Mac OS (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/socket_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 static bool JoinOrLeaveMulticast(intptr_t fd, 594 static bool JoinOrLeaveMulticast(intptr_t fd,
595 RawAddr* addr, 595 RawAddr* addr,
596 RawAddr* interface, 596 RawAddr* interface,
597 int interfaceIndex, 597 int interfaceIndex,
598 bool join) { 598 bool join) {
599 if (addr->addr.sa_family == AF_INET) { 599 if (addr->addr.sa_family == AF_INET) {
600 ASSERT(interface->addr.sa_family == AF_INET); 600 ASSERT(interface->addr.sa_family == AF_INET);
601 struct ip_mreq mreq; 601 struct ip_mreq mreq;
602 memmove(&mreq.imr_multiaddr, 602 memmove(&mreq.imr_multiaddr,
603 &addr->in.sin_addr, 603 &addr->in.sin_addr,
604 SocketAddress::GetAddrLength(addr)); 604 SocketAddress::GetInAddrLength(addr));
605 memmove(&mreq.imr_interface, 605 memmove(&mreq.imr_interface,
606 &interface->in.sin_addr, 606 &interface->in.sin_addr,
607 SocketAddress::GetAddrLength(interface)); 607 SocketAddress::GetInAddrLength(interface));
608 if (join) { 608 if (join) {
609 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt( 609 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt(
610 fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))) == 0; 610 fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))) == 0;
611 } else { 611 } else {
612 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt( 612 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt(
613 fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq))) == 0; 613 fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq))) == 0;
614 } 614 }
615 } else { 615 } else {
616 ASSERT(addr->addr.sa_family == AF_INET6); 616 ASSERT(addr->addr.sa_family == AF_INET6);
617 struct ipv6_mreq mreq; 617 struct ipv6_mreq mreq;
618 memmove(&mreq.ipv6mr_multiaddr, 618 memmove(&mreq.ipv6mr_multiaddr,
619 &addr->in6.sin6_addr, 619 &addr->in6.sin6_addr,
620 SocketAddress::GetAddrLength(addr)); 620 SocketAddress::GetInAddrLength(addr));
621 mreq.ipv6mr_interface = interfaceIndex; 621 mreq.ipv6mr_interface = interfaceIndex;
622 if (join) { 622 if (join) {
623 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt( 623 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt(
624 fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq))) == 0; 624 fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq))) == 0;
625 } else { 625 } else {
626 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt( 626 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt(
627 fd, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; 627 fd, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0;
628 } 628 }
629 } 629 }
630 } 630 }
631 631
632 bool Socket::JoinMulticast( 632 bool Socket::JoinMulticast(
633 intptr_t fd, RawAddr* addr, RawAddr* interface, int interfaceIndex) { 633 intptr_t fd, RawAddr* addr, RawAddr* interface, int interfaceIndex) {
634 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, true); 634 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, true);
Anders Johnsen 2013/12/18 11:29:49 Indentation here and line above.
Søren Gjesse 2013/12/18 11:56:29 Done.
635 if (addr->addr.sa_family == AF_INET) {
636 ASSERT(interface->addr.sa_family == AF_INET);
637 struct ip_mreq mreq;
638 memmove(&mreq.imr_multiaddr,
639 &addr->in.sin_addr,
640 SocketAddress::GetAddrLength(addr));
641 memmove(&mreq.imr_interface,
642 &interface->in.sin_addr,
643 SocketAddress::GetAddrLength(interface));
644 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt(
645 fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))) == 0;
646 } else {
647 ASSERT(addr->addr.sa_family == AF_INET6);
648 ASSERT(interface->addr.sa_family == AF_INET6);
649 struct ipv6_mreq mreq;
650 memmove(&mreq.ipv6mr_multiaddr,
651 &addr->in6.sin6_addr,
652 SocketAddress::GetAddrLength(addr));
653 mreq.ipv6mr_interface = interfaceIndex;
654 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt(
655 fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq))) == 0;
656 }
657 } 635 }
658 636
659 637
660 bool Socket::LeaveMulticast( 638 bool Socket::LeaveMulticast(
661 intptr_t fd, RawAddr* addr, RawAddr* interface, int interfaceIndex) { 639 intptr_t fd, RawAddr* addr, RawAddr* interface, int interfaceIndex) {
662 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, false); 640 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, false);
663 } 641 }
664 642
665 } // namespace bin 643 } // namespace bin
666 } // namespace dart 644 } // namespace dart
667 645
668 #endif // defined(TARGET_OS_MACOS) 646 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698