Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "bin/eventhandler_win.h" | 9 #include "bin/eventhandler_win.h" |
| 10 | 10 |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 982 HandleIssueError(); | 982 HandleIssueError(); |
| 983 return false; | 983 return false; |
| 984 } | 984 } |
| 985 | 985 |
| 986 | 986 |
| 987 bool DatagramSocket::IssueRecvFrom() { | 987 bool DatagramSocket::IssueRecvFrom() { |
| 988 MonitorLocker ml(monitor_); | 988 MonitorLocker ml(monitor_); |
| 989 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); | 989 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
| 990 ASSERT(pending_read_ == NULL); | 990 ASSERT(pending_read_ == NULL); |
| 991 | 991 |
| 992 OverlappedBuffer* buffer = OverlappedBuffer::AllocateRecvFromBuffer(1024); | 992 OverlappedBuffer* buffer = |
| 993 OverlappedBuffer::AllocateRecvFromBuffer(64 * 1024); | |
|
kustermann
2015/10/02 15:36:58
Maybe make a constant kMaxUDPPackageLength ?
[The
Søren Gjesse
2015/10/06 07:01:42
Added a constant and mentioned the current limit i
| |
| 993 | 994 |
| 994 DWORD flags; | 995 DWORD flags; |
| 995 flags = 0; | 996 flags = 0; |
| 996 int rc = WSARecvFrom(socket(), | 997 int rc = WSARecvFrom(socket(), |
| 997 buffer->GetWASBUF(), | 998 buffer->GetWASBUF(), |
| 998 1, | 999 1, |
| 999 NULL, | 1000 NULL, |
| 1000 &flags, | 1001 &flags, |
| 1001 buffer->from(), | 1002 buffer->from(), |
| 1002 buffer->from_len_addr(), | 1003 buffer->from_len_addr(), |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 } | 1206 } |
| 1206 | 1207 |
| 1207 DeleteIfClosed(handle); | 1208 DeleteIfClosed(handle); |
| 1208 } | 1209 } |
| 1209 | 1210 |
| 1210 | 1211 |
| 1211 void EventHandlerImplementation::HandleRecvFrom(Handle* handle, | 1212 void EventHandlerImplementation::HandleRecvFrom(Handle* handle, |
| 1212 int bytes, | 1213 int bytes, |
| 1213 OverlappedBuffer* buffer) { | 1214 OverlappedBuffer* buffer) { |
| 1214 ASSERT(handle->is_datagram_socket()); | 1215 ASSERT(handle->is_datagram_socket()); |
| 1215 buffer->set_data_length(bytes); | 1216 if (bytes >= 0) { |
| 1216 handle->ReadComplete(buffer); | 1217 buffer->set_data_length(bytes); |
| 1217 if (!handle->IsClosing()) { | 1218 handle->ReadComplete(buffer); |
| 1218 int event_mask = 1 << kInEvent; | 1219 if (!handle->IsClosing()) { |
| 1219 if ((handle->Mask() & event_mask) != 0) { | 1220 int event_mask = 1 << kInEvent; |
| 1221 if ((handle->Mask() & event_mask) != 0) { | |
| 1220 Dart_Port port = handle->NextNotifyDartPort(event_mask); | 1222 Dart_Port port = handle->NextNotifyDartPort(event_mask); |
| 1221 DartUtils::PostInt32(port, event_mask); | 1223 DartUtils::PostInt32(port, event_mask); |
| 1224 } | |
| 1222 } | 1225 } |
| 1226 } else { | |
| 1227 HandleError(handle); | |
|
kustermann
2015/10/02 15:36:58
Is there a way to test that we report the error to
Søren Gjesse
2015/10/06 07:01:42
I have not found one. I did a manual test with the
| |
| 1223 } | 1228 } |
| 1224 | 1229 |
| 1230 | |
|
kustermann
2015/10/02 15:36:58
extra empty line
Søren Gjesse
2015/10/06 07:01:42
Removed.
| |
| 1225 DeleteIfClosed(handle); | 1231 DeleteIfClosed(handle); |
| 1226 } | 1232 } |
| 1227 | 1233 |
| 1228 | 1234 |
| 1229 void EventHandlerImplementation::HandleWrite(Handle* handle, | 1235 void EventHandlerImplementation::HandleWrite(Handle* handle, |
| 1230 int bytes, | 1236 int bytes, |
| 1231 OverlappedBuffer* buffer) { | 1237 OverlappedBuffer* buffer) { |
| 1232 handle->WriteComplete(buffer); | 1238 handle->WriteComplete(buffer); |
| 1233 | 1239 |
| 1234 if (bytes >= 0) { | 1240 if (bytes >= 0) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1406 // accept requests for a listen socket which is closed. | 1412 // accept requests for a listen socket which is closed. |
| 1407 // ERROR_NETNAME_DELETED occurs when the client closes | 1413 // ERROR_NETNAME_DELETED occurs when the client closes |
| 1408 // the socket it is reading from. | 1414 // the socket it is reading from. |
| 1409 DWORD last_error = GetLastError(); | 1415 DWORD last_error = GetLastError(); |
| 1410 if (last_error == ERROR_CONNECTION_ABORTED || | 1416 if (last_error == ERROR_CONNECTION_ABORTED || |
| 1411 last_error == ERROR_OPERATION_ABORTED || | 1417 last_error == ERROR_OPERATION_ABORTED || |
| 1412 last_error == ERROR_NETNAME_DELETED || | 1418 last_error == ERROR_NETNAME_DELETED || |
| 1413 last_error == ERROR_BROKEN_PIPE) { | 1419 last_error == ERROR_BROKEN_PIPE) { |
| 1414 ASSERT(bytes == 0); | 1420 ASSERT(bytes == 0); |
| 1415 handler_impl->HandleIOCompletion(bytes, key, overlapped); | 1421 handler_impl->HandleIOCompletion(bytes, key, overlapped); |
| 1422 } else if (last_error == ERROR_MORE_DATA) { | |
| 1423 // Don't ASSERT no bytes in this case. This can happen if the receive | |
| 1424 // buffer for datagram sockets is to small to contain a full datagram, | |
| 1425 // and in this case bytes hold the bytes that was read. | |
| 1426 handler_impl->HandleIOCompletion(-1, key, overlapped); | |
| 1416 } else { | 1427 } else { |
| 1417 ASSERT(bytes == 0); | 1428 ASSERT(bytes == 0); |
| 1418 handler_impl->HandleIOCompletion(-1, key, overlapped); | 1429 handler_impl->HandleIOCompletion(-1, key, overlapped); |
| 1419 } | 1430 } |
| 1420 } else if (key == NULL) { | 1431 } else if (key == NULL) { |
| 1421 // A key of NULL signals an interrupt message. | 1432 // A key of NULL signals an interrupt message. |
| 1422 InterruptMessage* msg = reinterpret_cast<InterruptMessage*>(overlapped); | 1433 InterruptMessage* msg = reinterpret_cast<InterruptMessage*>(overlapped); |
| 1423 handler_impl->HandleInterrupt(msg); | 1434 handler_impl->HandleInterrupt(msg); |
| 1424 delete msg; | 1435 delete msg; |
| 1425 } else { | 1436 } else { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1452 | 1463 |
| 1453 | 1464 |
| 1454 void EventHandlerImplementation::Shutdown() { | 1465 void EventHandlerImplementation::Shutdown() { |
| 1455 SendData(kShutdownId, 0, 0); | 1466 SendData(kShutdownId, 0, 0); |
| 1456 } | 1467 } |
| 1457 | 1468 |
| 1458 } // namespace bin | 1469 } // namespace bin |
| 1459 } // namespace dart | 1470 } // namespace dart |
| 1460 | 1471 |
| 1461 #endif // defined(TARGET_OS_WINDOWS) | 1472 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |