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

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

Issue 2211523002: Make Mac-port non-blocking. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add 'on Mac' to Changelog. Created 4 years, 4 months 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
« no previous file with comments | « CHANGELOG.md ('k') | no next file » | 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 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(TARGET_OS_MACOS) 8 #if defined(TARGET_OS_MACOS)
9 9
10 #include "bin/socket.h" 10 #include "bin/socket.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 53
54 static intptr_t Create(const RawAddr& addr) { 54 static intptr_t Create(const RawAddr& addr) {
55 intptr_t fd; 55 intptr_t fd;
56 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0)); 56 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0));
57 if (fd < 0) { 57 if (fd < 0) {
58 return -1; 58 return -1;
59 } 59 }
60 FDUtils::SetCloseOnExec(fd); 60 FDUtils::SetCloseOnExec(fd);
61 FDUtils::SetNonBlocking(fd);
61 return fd; 62 return fd;
62 } 63 }
63 64
64 65
65 static intptr_t Connect(intptr_t fd, const RawAddr& addr) { 66 static intptr_t Connect(intptr_t fd, const RawAddr& addr) {
66 intptr_t result = TEMP_FAILURE_RETRY( 67 intptr_t result = TEMP_FAILURE_RETRY(
67 connect(fd, &addr.addr, SocketAddress::GetAddrLength(addr))); 68 connect(fd, &addr.addr, SocketAddress::GetAddrLength(addr)));
68 if ((result == 0) || (errno == EINPROGRESS)) { 69 if ((result == 0) || (errno == EINPROGRESS)) {
69 return fd; 70 return fd;
70 } 71 }
71 VOID_TEMP_FAILURE_RETRY(close(fd)); 72 VOID_TEMP_FAILURE_RETRY(close(fd));
72 return -1; 73 return -1;
73 } 74 }
74 75
75 76
76 intptr_t Socket::CreateConnect(const RawAddr& addr) { 77 intptr_t Socket::CreateConnect(const RawAddr& addr) {
77 intptr_t fd = Create(addr); 78 intptr_t fd = Create(addr);
78 if (fd < 0) { 79 if (fd < 0) {
79 return fd; 80 return fd;
80 } 81 }
81 82
82 FDUtils::SetNonBlocking(fd);
83
84 return Connect(fd, addr); 83 return Connect(fd, addr);
85 } 84 }
86 85
87 86
88 intptr_t Socket::CreateBindConnect(const RawAddr& addr, 87 intptr_t Socket::CreateBindConnect(const RawAddr& addr,
89 const RawAddr& source_addr) { 88 const RawAddr& source_addr) {
90 intptr_t fd = Create(addr); 89 intptr_t fd = Create(addr);
91 if (fd < 0) { 90 if (fd < 0) {
92 return fd; 91 return fd;
93 } 92 }
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 int interfaceIndex) { 630 int interfaceIndex) {
632 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, false); 631 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, false);
633 } 632 }
634 633
635 } // namespace bin 634 } // namespace bin
636 } // namespace dart 635 } // namespace dart
637 636
638 #endif // defined(TARGET_OS_MACOS) 637 #endif // defined(TARGET_OS_MACOS)
639 638
640 #endif // !defined(DART_IO_DISABLED) 639 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698