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

Unified Diff: runtime/bin/eventhandler_win.cc

Issue 1381233003: Increase the datagram receive buffer on Windows to 64k (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Removed tabs Created 5 years, 2 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 | « no previous file | sdk/lib/io/socket.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_win.cc
diff --git a/runtime/bin/eventhandler_win.cc b/runtime/bin/eventhandler_win.cc
index 6e27f821fb2a5fe603b02d80f04af957f6212f2c..33f59d6b3397232271c360ac037c5a0569151d04 100644
--- a/runtime/bin/eventhandler_win.cc
+++ b/runtime/bin/eventhandler_win.cc
@@ -29,6 +29,7 @@ namespace bin {
static const int kBufferSize = 64 * 1024;
static const int kStdOverlappedBufferSize = 16 * 1024;
+static const int kMaxUDPPackageLength = 64 * 1024;
OverlappedBuffer* OverlappedBuffer::AllocateBuffer(int buffer_size,
Operation operation) {
@@ -989,7 +990,8 @@ bool DatagramSocket::IssueRecvFrom() {
ASSERT(completion_port_ != INVALID_HANDLE_VALUE);
ASSERT(pending_read_ == NULL);
- OverlappedBuffer* buffer = OverlappedBuffer::AllocateRecvFromBuffer(1024);
+ OverlappedBuffer* buffer =
+ OverlappedBuffer::AllocateRecvFromBuffer(kMaxUDPPackageLength);
DWORD flags;
flags = 0;
@@ -1212,14 +1214,18 @@ void EventHandlerImplementation::HandleRecvFrom(Handle* handle,
int bytes,
OverlappedBuffer* buffer) {
ASSERT(handle->is_datagram_socket());
- buffer->set_data_length(bytes);
- handle->ReadComplete(buffer);
- if (!handle->IsClosing()) {
- int event_mask = 1 << kInEvent;
- if ((handle->Mask() & event_mask) != 0) {
+ if (bytes >= 0) {
+ buffer->set_data_length(bytes);
+ handle->ReadComplete(buffer);
+ if (!handle->IsClosing()) {
+ int event_mask = 1 << kInEvent;
+ if ((handle->Mask() & event_mask) != 0) {
Dart_Port port = handle->NextNotifyDartPort(event_mask);
- DartUtils::PostInt32(port, event_mask);
+ DartUtils::PostInt32(port, event_mask);
+ }
}
+ } else {
+ HandleError(handle);
}
DeleteIfClosed(handle);
@@ -1413,6 +1419,11 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
last_error == ERROR_BROKEN_PIPE) {
ASSERT(bytes == 0);
handler_impl->HandleIOCompletion(bytes, key, overlapped);
+ } else if (last_error == ERROR_MORE_DATA) {
+ // Don't ASSERT no bytes in this case. This can happen if the receive
+ // buffer for datagram sockets is to small to contain a full datagram,
+ // and in this case bytes hold the bytes that was read.
+ handler_impl->HandleIOCompletion(-1, key, overlapped);
} else {
ASSERT(bytes == 0);
handler_impl->HandleIOCompletion(-1, key, overlapped);
« no previous file with comments | « no previous file | sdk/lib/io/socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698