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

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

Issue 9837060: Treat EAGAIN/EWOULDBLOCK as requests for retry on socket accept. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« runtime/bin/socket_linux.cc ('K') | « runtime/bin/socket_linux.cc ('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) 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 <arpa/inet.h> 5 #include <arpa/inet.h>
6 #include <errno.h> 6 #include <errno.h>
7 #include <netdb.h> 7 #include <netdb.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 if (TEMP_FAILURE_RETRY(listen(fd, backlog)) != 0) { 183 if (TEMP_FAILURE_RETRY(listen(fd, backlog)) != 0) {
184 fprintf(stderr, "Error Listen: %s\n", strerror(errno)); 184 fprintf(stderr, "Error Listen: %s\n", strerror(errno));
185 return -1; 185 return -1;
186 } 186 }
187 187
188 FDUtils::SetNonBlocking(fd); 188 FDUtils::SetNonBlocking(fd);
189 return fd; 189 return fd;
190 } 190 }
191 191
192
192 intptr_t ServerSocket::Accept(intptr_t fd) { 193 intptr_t ServerSocket::Accept(intptr_t fd) {
193 intptr_t socket; 194 intptr_t socket;
194 struct sockaddr clientaddr; 195 struct sockaddr clientaddr;
195 socklen_t addrlen = sizeof(clientaddr); 196 socklen_t addrlen = sizeof(clientaddr);
196 socket = TEMP_FAILURE_RETRY(accept(fd, &clientaddr, &addrlen)); 197 socket = TEMP_FAILURE_RETRY(accept(fd, &clientaddr, &addrlen));
197 if (socket < 0) { 198 if (socket == -1) {
198 fprintf(stderr, "Error Accept: %s\n", strerror(errno)); 199 if (errno == EAGAIN) {
200 // We need to signal to the caller that this is actually not an
201 // error. We got woken up from the poll on the listening socket,
202 // but there is no connection ready to be accepted.
203 ASSERT(kTemporaryFailure != -1);
204 socket = kTemporaryFailure;
205 } else {
206 fprintf(stderr, "Error Accept: %s\n", strerror(errno));
Ivan Posva 2012/03/23 21:09:48 ditto.
207 }
199 } else { 208 } else {
200 FDUtils::SetNonBlocking(socket); 209 FDUtils::SetNonBlocking(socket);
201 } 210 }
202 return socket; 211 return socket;
203 } 212 }
OLDNEW
« runtime/bin/socket_linux.cc ('K') | « runtime/bin/socket_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698