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

Side by Side Diff: runtime/bin/eventhandler_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, 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/main.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) 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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <winsock2.h> // NOLINT 10 #include <winsock2.h> // NOLINT
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 571
572 572
573 ClientSocket* ListenSocket::Accept() { 573 ClientSocket* ListenSocket::Accept() {
574 ScopedLock lock(this); 574 ScopedLock lock(this);
575 if (accepted_head_ == NULL) return NULL; 575 if (accepted_head_ == NULL) return NULL;
576 ClientSocket* result = accepted_head_; 576 ClientSocket* result = accepted_head_;
577 accepted_head_ = accepted_head_->next(); 577 accepted_head_ = accepted_head_->next();
578 if (accepted_head_ == NULL) accepted_tail_ = NULL; 578 if (accepted_head_ == NULL) accepted_tail_ = NULL;
579 result->set_next(NULL); 579 result->set_next(NULL);
580 if (!IsClosing()) { 580 if (!IsClosing()) {
581 while (pending_accept_count() < 5) { 581 if (!IssueAccept()) {
582 if (!IssueAccept()) { 582 HandleError(this);
583 HandleError(this);
584 }
585 } 583 }
586 } 584 }
587 return result; 585 return result;
588 } 586 }
589 587
590 588
591 void ListenSocket::EnsureInitialized( 589 void ListenSocket::EnsureInitialized(
592 EventHandlerImplementation* event_handler) { 590 EventHandlerImplementation* event_handler) {
593 ScopedLock lock(this); 591 ScopedLock lock(this);
594 if (AcceptEx_ == NULL) { 592 if (AcceptEx_ == NULL) {
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 Handle::ScopedLock lock(listen_socket); 1031 Handle::ScopedLock lock(listen_socket);
1034 1032
1035 // If incoming connections are requested make sure to post already 1033 // If incoming connections are requested make sure to post already
1036 // accepted connections. 1034 // accepted connections.
1037 if ((msg->data & (1 << kInEvent)) != 0) { 1035 if ((msg->data & (1 << kInEvent)) != 0) {
1038 if (listen_socket->CanAccept()) { 1036 if (listen_socket->CanAccept()) {
1039 int event_mask = (1 << kInEvent); 1037 int event_mask = (1 << kInEvent);
1040 handle->set_mask(handle->mask() & ~event_mask); 1038 handle->set_mask(handle->mask() & ~event_mask);
1041 DartUtils::PostInt32(handle->port(), event_mask); 1039 DartUtils::PostInt32(handle->port(), event_mask);
1042 } 1040 }
1043 // Always keep 5 outstanding accepts going, to enhance performance.
1044 while (listen_socket->pending_accept_count() < 5) {
1045 bool accept_success = listen_socket->IssueAccept();
1046 if (!accept_success) {
1047 HandleError(listen_socket);
1048 break;
1049 }
1050 }
1051 } 1041 }
1052 } else { 1042 } else {
1053 handle->EnsureInitialized(this); 1043 handle->EnsureInitialized(this);
1054 1044
1055 Handle::ScopedLock lock(handle); 1045 Handle::ScopedLock lock(handle);
1056 1046
1057 // Only set mask if we turned on kInEvent or kOutEvent. 1047 // Only set mask if we turned on kInEvent or kOutEvent.
1058 if ((msg->data & ((1 << kInEvent) | (1 << kOutEvent))) != 0) { 1048 if ((msg->data & ((1 << kInEvent) | (1 << kOutEvent))) != 0) {
1059 handle->SetPortAndMask(msg->dart_port, msg->data); 1049 handle->SetPortAndMask(msg->dart_port, msg->data);
1060 } 1050 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 1362
1373 1363
1374 void EventHandlerImplementation::Shutdown() { 1364 void EventHandlerImplementation::Shutdown() {
1375 SendData(kShutdownId, 0, 0); 1365 SendData(kShutdownId, 0, 0);
1376 } 1366 }
1377 1367
1378 } // namespace bin 1368 } // namespace bin
1379 } // namespace dart 1369 } // namespace dart
1380 1370
1381 #endif // defined(TARGET_OS_WINDOWS) 1371 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698