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

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

Issue 2830273002: [dart:io][windows] Implements RawSynchronousSocket (Closed)
Patch Set: Fix Linux build Created 3 years, 8 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 | « runtime/bin/socket_base_android.cc ('k') | runtime/bin/socket_base_linux.cc » ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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(HOST_OS_FUCHSIA) 8 #if defined(HOST_OS_FUCHSIA)
9 9
10 #include "bin/socket_base.h" 10 #include "bin/socket_base.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 88
89 intptr_t SocketBase::Available(intptr_t fd) { 89 intptr_t SocketBase::Available(intptr_t fd) {
90 intptr_t available = FDUtils::AvailableBytes(fd); 90 intptr_t available = FDUtils::AvailableBytes(fd);
91 LOG_INFO("SocketBase::Available(%ld) = %ld\n", fd, available); 91 LOG_INFO("SocketBase::Available(%ld) = %ld\n", fd, available);
92 return available; 92 return available;
93 } 93 }
94 94
95 95
96 intptr_t SocketBase::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { 96 intptr_t SocketBase::Read(intptr_t fd,
97 void* buffer,
98 intptr_t num_bytes,
99 SocketOpKind sync) {
97 ASSERT(fd >= 0); 100 ASSERT(fd >= 0);
98 LOG_INFO("SocketBase::Read: calling read(%ld, %p, %ld)\n", fd, buffer, 101 LOG_INFO("SocketBase::Read: calling read(%ld, %p, %ld)\n", fd, buffer,
99 num_bytes); 102 num_bytes);
100 ssize_t read_bytes = NO_RETRY_EXPECTED(read(fd, buffer, num_bytes)); 103 ssize_t read_bytes = NO_RETRY_EXPECTED(read(fd, buffer, num_bytes));
101 ASSERT(EAGAIN == EWOULDBLOCK); 104 ASSERT(EAGAIN == EWOULDBLOCK);
102 if ((read_bytes == -1) && (errno == EWOULDBLOCK)) { 105 if ((sync == kAsync) && (read_bytes == -1) && (errno == EWOULDBLOCK)) {
103 // If the read would block we need to retry and therefore return 0 106 // If the read would block we need to retry and therefore return 0
104 // as the number of bytes written. 107 // as the number of bytes written.
105 read_bytes = 0; 108 read_bytes = 0;
106 } else if (read_bytes == -1) { 109 } else if (read_bytes == -1) {
107 LOG_ERR("SocketBase::Read: read(%ld, %p, %ld) failed\n", fd, buffer, 110 LOG_ERR("SocketBase::Read: read(%ld, %p, %ld) failed\n", fd, buffer,
108 num_bytes); 111 num_bytes);
109 } else { 112 } else {
110 LOG_INFO("SocketBase::Read: read(%ld, %p, %ld) succeeded\n", fd, buffer, 113 LOG_INFO("SocketBase::Read: read(%ld, %p, %ld) succeeded\n", fd, buffer,
111 num_bytes); 114 num_bytes);
112 } 115 }
113 return read_bytes; 116 return read_bytes;
114 } 117 }
115 118
116 119
117 intptr_t SocketBase::RecvFrom(intptr_t fd, 120 intptr_t SocketBase::RecvFrom(intptr_t fd,
118 void* buffer, 121 void* buffer,
119 intptr_t num_bytes, 122 intptr_t num_bytes,
120 RawAddr* addr) { 123 RawAddr* addr,
124 SocketOpKind sync) {
121 LOG_ERR("SocketBase::RecvFrom is unimplemented\n"); 125 LOG_ERR("SocketBase::RecvFrom is unimplemented\n");
122 UNIMPLEMENTED(); 126 UNIMPLEMENTED();
123 return -1; 127 return -1;
124 } 128 }
125 129
126 130
127 intptr_t SocketBase::Write(intptr_t fd, 131 intptr_t SocketBase::Write(intptr_t fd,
128 const void* buffer, 132 const void* buffer,
129 intptr_t num_bytes) { 133 intptr_t num_bytes,
134 SocketOpKind sync) {
130 ASSERT(fd >= 0); 135 ASSERT(fd >= 0);
131 LOG_INFO("SocketBase::Write: calling write(%ld, %p, %ld)\n", fd, buffer, 136 LOG_INFO("SocketBase::Write: calling write(%ld, %p, %ld)\n", fd, buffer,
132 num_bytes); 137 num_bytes);
133 ssize_t written_bytes = NO_RETRY_EXPECTED(write(fd, buffer, num_bytes)); 138 ssize_t written_bytes = NO_RETRY_EXPECTED(write(fd, buffer, num_bytes));
134 ASSERT(EAGAIN == EWOULDBLOCK); 139 ASSERT(EAGAIN == EWOULDBLOCK);
135 if ((written_bytes == -1) && (errno == EWOULDBLOCK)) { 140 if ((sync == kAsync) && (written_bytes == -1) && (errno == EWOULDBLOCK)) {
136 // If the would block we need to retry and therefore return 0 as 141 // If the would block we need to retry and therefore return 0 as
137 // the number of bytes written. 142 // the number of bytes written.
138 written_bytes = 0; 143 written_bytes = 0;
139 } else if (written_bytes == -1) { 144 } else if (written_bytes == -1) {
140 LOG_ERR("SocketBase::Write: write(%ld, %p, %ld) failed\n", fd, buffer, 145 LOG_ERR("SocketBase::Write: write(%ld, %p, %ld) failed\n", fd, buffer,
141 num_bytes); 146 num_bytes);
142 } else { 147 } else {
143 LOG_INFO("SocketBase::Write: write(%ld, %p, %ld) succeeded\n", fd, buffer, 148 LOG_INFO("SocketBase::Write: write(%ld, %p, %ld) succeeded\n", fd, buffer,
144 num_bytes); 149 num_bytes);
145 } 150 }
146 return written_bytes; 151 return written_bytes;
147 } 152 }
148 153
149 154
150 intptr_t SocketBase::SendTo(intptr_t fd, 155 intptr_t SocketBase::SendTo(intptr_t fd,
151 const void* buffer, 156 const void* buffer,
152 intptr_t num_bytes, 157 intptr_t num_bytes,
153 const RawAddr& addr) { 158 const RawAddr& addr,
159 SocketOpKind sync) {
154 LOG_ERR("SocketBase::SendTo is unimplemented\n"); 160 LOG_ERR("SocketBase::SendTo is unimplemented\n");
155 UNIMPLEMENTED(); 161 UNIMPLEMENTED();
156 return -1; 162 return -1;
157 } 163 }
158 164
159 165
160 intptr_t SocketBase::GetPort(intptr_t fd) { 166 intptr_t SocketBase::GetPort(intptr_t fd) {
161 ASSERT(fd >= 0); 167 ASSERT(fd >= 0);
162 RawAddr raw; 168 RawAddr raw;
163 socklen_t size = sizeof(raw); 169 socklen_t size = sizeof(raw);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 UNIMPLEMENTED(); 373 UNIMPLEMENTED();
368 return false; 374 return false;
369 } 375 }
370 376
371 } // namespace bin 377 } // namespace bin
372 } // namespace dart 378 } // namespace dart
373 379
374 #endif // defined(HOST_OS_FUCHSIA) 380 #endif // defined(HOST_OS_FUCHSIA)
375 381
376 #endif // !defined(DART_IO_DISABLED) 382 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/socket_base_android.cc ('k') | runtime/bin/socket_base_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698