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

Unified Diff: runtime/bin/socket_win.cc

Issue 426613002: Start accepting incoming sockets earlier on Windows, to associate a at AcceptEx error to 'ServerSoc… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
« no previous file with comments | « runtime/bin/socket_macos.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_win.cc
diff --git a/runtime/bin/socket_win.cc b/runtime/bin/socket_win.cc
index 18156e69d160d08749a2073296057bdebeeeec0e..4a9e2807e3f3d52c8197f53644230559c9ebbb73 100644
--- a/runtime/bin/socket_win.cc
+++ b/runtime/bin/socket_win.cc
@@ -525,6 +525,27 @@ intptr_t ServerSocket::CreateBindListen(RawAddr addr,
}
+bool ServerSocket::StartAccept(intptr_t fd) {
+ ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(fd);
+ listen_socket->EnsureInitialized(EventHandler::delegate());
+ // Always keep 5 outstanding accepts going, to enhance performance.
+ for (int i = 0; i < 5; i++) {
+ if (!listen_socket->IssueAccept()) {
+ DWORD rc = WSAGetLastError();
+ listen_socket->Close();
+ if (!listen_socket->HasPendingAccept()) {
+ // Delete socket now, if there are no pending accepts. Otherwise,
+ // the event-handler will take care of deleting it.
+ delete listen_socket;
+ }
+ SetLastError(rc);
+ return false;
+ }
+ }
+ return true;
+}
+
+
void Socket::Close(intptr_t fd) {
ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd);
client_socket->Close();
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698