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

Unified 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 side-by-side diff with in-line comments
Download patch
« runtime/bin/socket_linux.cc ('K') | « runtime/bin/socket_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_macos.cc
diff --git a/runtime/bin/socket_macos.cc b/runtime/bin/socket_macos.cc
index c9b82049ab7d31b0cdd7686bc96586dfb99bab9b..a460ed97bf46c50521fae47e02b09cb37d61b62a 100644
--- a/runtime/bin/socket_macos.cc
+++ b/runtime/bin/socket_macos.cc
@@ -189,13 +189,22 @@ intptr_t ServerSocket::CreateBindListen(const char* host,
return fd;
}
+
intptr_t ServerSocket::Accept(intptr_t fd) {
intptr_t socket;
struct sockaddr clientaddr;
socklen_t addrlen = sizeof(clientaddr);
socket = TEMP_FAILURE_RETRY(accept(fd, &clientaddr, &addrlen));
- if (socket < 0) {
- fprintf(stderr, "Error Accept: %s\n", strerror(errno));
+ if (socket == -1) {
+ if (errno == EAGAIN) {
+ // We need to signal to the caller that this is actually not an
+ // error. We got woken up from the poll on the listening socket,
+ // but there is no connection ready to be accepted.
+ ASSERT(kTemporaryFailure != -1);
+ socket = kTemporaryFailure;
+ } else {
+ fprintf(stderr, "Error Accept: %s\n", strerror(errno));
Ivan Posva 2012/03/23 21:09:48 ditto.
+ }
} else {
FDUtils::SetNonBlocking(socket);
}
« 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