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 | 9 |
10 #include <winsock2.h> // NOLINT | 10 #include <winsock2.h> // NOLINT |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 OverlappedBuffer* buffer = AllocateBuffer(buffer_size, kAccept); | 43 OverlappedBuffer* buffer = AllocateBuffer(buffer_size, kAccept); |
44 return buffer; | 44 return buffer; |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 OverlappedBuffer* OverlappedBuffer::AllocateReadBuffer(int buffer_size) { | 48 OverlappedBuffer* OverlappedBuffer::AllocateReadBuffer(int buffer_size) { |
49 return AllocateBuffer(buffer_size, kRead); | 49 return AllocateBuffer(buffer_size, kRead); |
50 } | 50 } |
51 | 51 |
52 | 52 |
| 53 OverlappedBuffer* OverlappedBuffer::AllocateRecvFromBuffer(int buffer_size) { |
| 54 // For calling recvfrom additional buffer space is needed for the source |
| 55 // address information. |
| 56 buffer_size += sizeof(socklen_t) + sizeof(struct sockaddr_storage); |
| 57 return AllocateBuffer(buffer_size, kRecvFrom); |
| 58 } |
| 59 |
| 60 |
53 OverlappedBuffer* OverlappedBuffer::AllocateWriteBuffer(int buffer_size) { | 61 OverlappedBuffer* OverlappedBuffer::AllocateWriteBuffer(int buffer_size) { |
54 return AllocateBuffer(buffer_size, kWrite); | 62 return AllocateBuffer(buffer_size, kWrite); |
55 } | 63 } |
56 | 64 |
57 | 65 |
| 66 OverlappedBuffer* OverlappedBuffer::AllocateSendToBuffer(int buffer_size) { |
| 67 return AllocateBuffer(buffer_size, kSendTo); |
| 68 } |
| 69 |
| 70 |
58 OverlappedBuffer* OverlappedBuffer::AllocateDisconnectBuffer() { | 71 OverlappedBuffer* OverlappedBuffer::AllocateDisconnectBuffer() { |
59 return AllocateBuffer(0, kDisconnect); | 72 return AllocateBuffer(0, kDisconnect); |
60 } | 73 } |
61 | 74 |
62 | 75 |
63 void OverlappedBuffer::DisposeBuffer(OverlappedBuffer* buffer) { | 76 void OverlappedBuffer::DisposeBuffer(OverlappedBuffer* buffer) { |
64 delete buffer; | 77 delete buffer; |
65 } | 78 } |
66 | 79 |
67 | 80 |
(...skipping 16 matching lines...) Expand all Loading... |
84 | 97 |
85 int OverlappedBuffer::Write(const void* buffer, int num_bytes) { | 98 int OverlappedBuffer::Write(const void* buffer, int num_bytes) { |
86 ASSERT(num_bytes == buflen_); | 99 ASSERT(num_bytes == buflen_); |
87 memmove(GetBufferStart(), buffer, num_bytes); | 100 memmove(GetBufferStart(), buffer, num_bytes); |
88 data_length_ = num_bytes; | 101 data_length_ = num_bytes; |
89 return num_bytes; | 102 return num_bytes; |
90 } | 103 } |
91 | 104 |
92 | 105 |
93 int OverlappedBuffer::GetRemainingLength() { | 106 int OverlappedBuffer::GetRemainingLength() { |
94 ASSERT(operation_ == kRead); | 107 ASSERT(operation_ == kRead || operation_ == kRecvFrom); |
95 return data_length_ - index_; | 108 return data_length_ - index_; |
96 } | 109 } |
97 | 110 |
98 | 111 |
99 Handle::Handle(HANDLE handle) | 112 Handle::Handle(HANDLE handle) |
100 : handle_(reinterpret_cast<HANDLE>(handle)), | 113 : handle_(reinterpret_cast<HANDLE>(handle)), |
101 port_(0), | 114 port_(0), |
102 mask_(0), | 115 mask_(0), |
103 completion_port_(INVALID_HANDLE_VALUE), | 116 completion_port_(INVALID_HANDLE_VALUE), |
104 event_handler_(NULL), | 117 event_handler_(NULL), |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 ASSERT(data_ready_ == NULL); | 205 ASSERT(data_ready_ == NULL); |
193 if (!IsClosing() && !buffer->IsEmpty()) { | 206 if (!IsClosing() && !buffer->IsEmpty()) { |
194 data_ready_ = pending_read_; | 207 data_ready_ = pending_read_; |
195 } else { | 208 } else { |
196 OverlappedBuffer::DisposeBuffer(buffer); | 209 OverlappedBuffer::DisposeBuffer(buffer); |
197 } | 210 } |
198 pending_read_ = NULL; | 211 pending_read_ = NULL; |
199 } | 212 } |
200 | 213 |
201 | 214 |
| 215 void Handle::RecvFromComplete(OverlappedBuffer* buffer) { |
| 216 ReadComplete(buffer); |
| 217 } |
| 218 |
| 219 |
202 void Handle::WriteComplete(OverlappedBuffer* buffer) { | 220 void Handle::WriteComplete(OverlappedBuffer* buffer) { |
203 ScopedLock lock(this); | 221 ScopedLock lock(this); |
204 // Currently only one outstanding write at the time. | 222 // Currently only one outstanding write at the time. |
205 ASSERT(pending_write_ == buffer); | 223 ASSERT(pending_write_ == buffer); |
206 OverlappedBuffer::DisposeBuffer(buffer); | 224 OverlappedBuffer::DisposeBuffer(buffer); |
207 pending_write_ = NULL; | 225 pending_write_ = NULL; |
208 } | 226 } |
209 | 227 |
210 | 228 |
211 static void ReadFileThread(uword args) { | 229 static void ReadFileThread(uword args) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 int result = dart::Thread::Start(ReadFileThread, | 290 int result = dart::Thread::Start(ReadFileThread, |
273 reinterpret_cast<uword>(this)); | 291 reinterpret_cast<uword>(this)); |
274 if (result != 0) { | 292 if (result != 0) { |
275 FATAL1("Failed to start read file thread %d", result); | 293 FATAL1("Failed to start read file thread %d", result); |
276 } | 294 } |
277 return true; | 295 return true; |
278 } | 296 } |
279 } | 297 } |
280 | 298 |
281 | 299 |
| 300 bool Handle::IssueRecvFrom() { |
| 301 return false; |
| 302 } |
| 303 |
| 304 |
282 bool Handle::IssueWrite() { | 305 bool Handle::IssueWrite() { |
283 ScopedLock lock(this); | 306 ScopedLock lock(this); |
284 ASSERT(type_ != kListenSocket); | 307 ASSERT(type_ != kListenSocket); |
285 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); | 308 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
286 ASSERT(pending_write_ != NULL); | 309 ASSERT(pending_write_ != NULL); |
287 ASSERT(pending_write_->operation() == OverlappedBuffer::kWrite); | 310 ASSERT(pending_write_->operation() == OverlappedBuffer::kWrite); |
288 | 311 |
289 OverlappedBuffer* buffer = pending_write_; | 312 OverlappedBuffer* buffer = pending_write_; |
290 BOOL ok = WriteFile(handle_, | 313 BOOL ok = WriteFile(handle_, |
291 buffer->GetBufferStart(), | 314 buffer->GetBufferStart(), |
292 buffer->GetBufferSize(), | 315 buffer->GetBufferSize(), |
293 NULL, | 316 NULL, |
294 buffer->GetCleanOverlapped()); | 317 buffer->GetCleanOverlapped()); |
295 if (ok || GetLastError() == ERROR_IO_PENDING) { | 318 if (ok || GetLastError() == ERROR_IO_PENDING) { |
296 // Completing asynchronously. | 319 // Completing asynchronously. |
297 pending_write_ = buffer; | 320 pending_write_ = buffer; |
298 return true; | 321 return true; |
299 } | 322 } |
300 OverlappedBuffer::DisposeBuffer(buffer); | 323 OverlappedBuffer::DisposeBuffer(buffer); |
301 HandleIssueError(); | 324 HandleIssueError(); |
302 return false; | 325 return false; |
303 } | 326 } |
304 | 327 |
305 | 328 |
| 329 bool Handle::IssueSendTo(struct sockaddr* sa, socklen_t sa_len) { |
| 330 return false; |
| 331 } |
| 332 |
| 333 |
306 void Handle::HandleIssueError() { | 334 void Handle::HandleIssueError() { |
307 DWORD error = GetLastError(); | 335 DWORD error = GetLastError(); |
308 if (error == ERROR_BROKEN_PIPE) { | 336 if (error == ERROR_BROKEN_PIPE) { |
309 event_handler_->HandleClosed(this); | 337 event_handler_->HandleClosed(this); |
310 } else { | 338 } else { |
311 event_handler_->HandleError(this); | 339 event_handler_->HandleError(this); |
312 } | 340 } |
313 SetLastError(error); | 341 SetLastError(error); |
314 } | 342 } |
315 | 343 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 if (data_ready_ == NULL) return 0; | 564 if (data_ready_ == NULL) return 0; |
537 num_bytes = data_ready_->Read(buffer, num_bytes); | 565 num_bytes = data_ready_->Read(buffer, num_bytes); |
538 if (data_ready_->IsEmpty()) { | 566 if (data_ready_->IsEmpty()) { |
539 OverlappedBuffer::DisposeBuffer(data_ready_); | 567 OverlappedBuffer::DisposeBuffer(data_ready_); |
540 data_ready_ = NULL; | 568 data_ready_ = NULL; |
541 } | 569 } |
542 return num_bytes; | 570 return num_bytes; |
543 } | 571 } |
544 | 572 |
545 | 573 |
| 574 int Handle::RecvFrom( |
| 575 void* buffer, int num_bytes, struct sockaddr* sa, socklen_t sa_len) { |
| 576 ScopedLock lock(this); |
| 577 if (data_ready_ == NULL) return 0; |
| 578 num_bytes = data_ready_->Read(buffer, num_bytes); |
| 579 if (data_ready_->from()->sa_family == AF_INET) { |
| 580 ASSERT(sa_len >= sizeof(struct sockaddr_in)); |
| 581 memmove(sa, data_ready_->from(), sizeof(struct sockaddr_in)); |
| 582 } else { |
| 583 ASSERT(data_ready_->from()->sa_family == AF_INET6); |
| 584 ASSERT(sa_len >= sizeof(struct sockaddr_in6)); |
| 585 memmove(sa, data_ready_->from(), sizeof(struct sockaddr_in6)); |
| 586 } |
| 587 // Always dispose of the buffer, as UDP messages must be read in their |
| 588 // entirety to match how recvfrom works in a socket. |
| 589 OverlappedBuffer::DisposeBuffer(data_ready_); |
| 590 data_ready_ = NULL; |
| 591 return num_bytes; |
| 592 } |
| 593 |
| 594 |
546 int Handle::Write(const void* buffer, int num_bytes) { | 595 int Handle::Write(const void* buffer, int num_bytes) { |
547 ScopedLock lock(this); | 596 ScopedLock lock(this); |
548 if (pending_write_ != NULL) return 0; | 597 if (pending_write_ != NULL) return 0; |
549 if (num_bytes > kBufferSize) num_bytes = kBufferSize; | 598 if (num_bytes > kBufferSize) num_bytes = kBufferSize; |
550 ASSERT(SupportsOverlappedIO()); | 599 ASSERT(SupportsOverlappedIO()); |
551 if (completion_port_ == INVALID_HANDLE_VALUE) return 0; | 600 if (completion_port_ == INVALID_HANDLE_VALUE) return 0; |
552 pending_write_ = OverlappedBuffer::AllocateWriteBuffer(num_bytes); | 601 pending_write_ = OverlappedBuffer::AllocateWriteBuffer(num_bytes); |
553 pending_write_->Write(buffer, num_bytes); | 602 pending_write_->Write(buffer, num_bytes); |
554 if (!IssueWrite()) return -1; | 603 if (!IssueWrite()) return -1; |
555 return num_bytes; | 604 return num_bytes; |
556 } | 605 } |
557 | 606 |
558 | 607 |
| 608 int Handle::SendTo( |
| 609 const void* buffer, int num_bytes, struct sockaddr* sa, socklen_t sa_len) { |
| 610 ScopedLock lock(this); |
| 611 if (pending_write_ != NULL) return 0; |
| 612 if (num_bytes > kBufferSize) num_bytes = kBufferSize; |
| 613 ASSERT(SupportsOverlappedIO()); |
| 614 if (completion_port_ == INVALID_HANDLE_VALUE) return 0; |
| 615 pending_write_ = OverlappedBuffer::AllocateSendToBuffer(num_bytes); |
| 616 pending_write_->Write(buffer, num_bytes); |
| 617 if (!IssueSendTo(sa, sa_len)) return -1; |
| 618 return num_bytes; |
| 619 } |
| 620 |
| 621 |
559 static void WriteFileThread(uword args) { | 622 static void WriteFileThread(uword args) { |
560 StdHandle* handle = reinterpret_cast<StdHandle*>(args); | 623 StdHandle* handle = reinterpret_cast<StdHandle*>(args); |
561 handle->RunWriteLoop(); | 624 handle->RunWriteLoop(); |
562 } | 625 } |
563 | 626 |
564 | 627 |
565 void StdHandle::RunWriteLoop() { | 628 void StdHandle::RunWriteLoop() { |
566 write_monitor_->Enter(); | 629 write_monitor_->Enter(); |
567 write_thread_running_ = true; | 630 write_thread_running_ = true; |
568 // Notify we have started. | 631 // Notify we have started. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 shutdown(socket(), SD_BOTH); | 763 shutdown(socket(), SD_BOTH); |
701 IssueDisconnect(); | 764 IssueDisconnect(); |
702 } | 765 } |
703 | 766 |
704 | 767 |
705 bool ClientSocket::IssueRead() { | 768 bool ClientSocket::IssueRead() { |
706 ScopedLock lock(this); | 769 ScopedLock lock(this); |
707 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); | 770 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
708 ASSERT(pending_read_ == NULL); | 771 ASSERT(pending_read_ == NULL); |
709 | 772 |
710 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(1024); | 773 // TODO(sgjesse): Use a MTU value here. Only the loopback adapter can |
| 774 // handle 64k datagrams. |
| 775 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(65536); |
711 | 776 |
712 DWORD flags; | 777 DWORD flags; |
713 flags = 0; | 778 flags = 0; |
714 int rc = WSARecv(socket(), | 779 int rc = WSARecv(socket(), |
715 buffer->GetWASBUF(), | 780 buffer->GetWASBUF(), |
716 1, | 781 1, |
717 NULL, | 782 NULL, |
718 &flags, | 783 &flags, |
719 buffer->GetCleanOverlapped(), | 784 buffer->GetCleanOverlapped(), |
720 NULL); | 785 NULL); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 CreateCompletionPort(event_handler_->completion_port()); | 849 CreateCompletionPort(event_handler_->completion_port()); |
785 } | 850 } |
786 } | 851 } |
787 | 852 |
788 | 853 |
789 bool ClientSocket::IsClosed() { | 854 bool ClientSocket::IsClosed() { |
790 return false; | 855 return false; |
791 } | 856 } |
792 | 857 |
793 | 858 |
| 859 bool DatagramSocket::IssueSendTo(struct sockaddr* sa, socklen_t sa_len) { |
| 860 ScopedLock lock(this); |
| 861 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
| 862 ASSERT(pending_write_ != NULL); |
| 863 ASSERT(pending_write_->operation() == OverlappedBuffer::kSendTo); |
| 864 |
| 865 int rc = WSASendTo(socket(), |
| 866 pending_write_->GetWASBUF(), |
| 867 1, |
| 868 NULL, |
| 869 0, |
| 870 sa, |
| 871 sa_len, |
| 872 pending_write_->GetCleanOverlapped(), |
| 873 NULL); |
| 874 if (rc == NO_ERROR || WSAGetLastError() == WSA_IO_PENDING) { |
| 875 return true; |
| 876 } |
| 877 OverlappedBuffer::DisposeBuffer(pending_write_); |
| 878 pending_write_ = NULL; |
| 879 HandleIssueError(); |
| 880 return false; |
| 881 } |
| 882 |
| 883 |
| 884 bool DatagramSocket::IssueRecvFrom() { |
| 885 ScopedLock lock(this); |
| 886 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
| 887 ASSERT(pending_read_ == NULL); |
| 888 |
| 889 OverlappedBuffer* buffer = OverlappedBuffer::AllocateRecvFromBuffer(1024); |
| 890 |
| 891 DWORD flags; |
| 892 flags = 0; |
| 893 int len; |
| 894 int rc = WSARecvFrom(socket(), |
| 895 buffer->GetWASBUF(), |
| 896 1, |
| 897 NULL, |
| 898 &flags, |
| 899 buffer->from(), |
| 900 buffer->from_len_addr(), |
| 901 buffer->GetCleanOverlapped(), |
| 902 NULL); |
| 903 if (rc == NO_ERROR || WSAGetLastError() == WSA_IO_PENDING) { |
| 904 pending_read_ = buffer; |
| 905 return true; |
| 906 } |
| 907 OverlappedBuffer::DisposeBuffer(buffer); |
| 908 pending_read_ = NULL; |
| 909 HandleIssueError(); |
| 910 return false; |
| 911 } |
| 912 |
| 913 |
| 914 void DatagramSocket::EnsureInitialized( |
| 915 EventHandlerImplementation* event_handler) { |
| 916 ScopedLock lock(this); |
| 917 if (completion_port_ == INVALID_HANDLE_VALUE) { |
| 918 ASSERT(event_handler_ == NULL); |
| 919 event_handler_ = event_handler; |
| 920 CreateCompletionPort(event_handler_->completion_port()); |
| 921 } |
| 922 } |
| 923 |
| 924 |
| 925 bool DatagramSocket::IsClosed() { |
| 926 return IsClosing() && !HasPendingRead() && !HasPendingWrite(); |
| 927 } |
| 928 |
| 929 |
| 930 void DatagramSocket::DoClose() { |
| 931 // Just close the socket. This will cause any queued requests to be aborted. |
| 932 closesocket(socket()); |
| 933 MarkClosedRead(); |
| 934 MarkClosedWrite(); |
| 935 } |
| 936 |
| 937 |
794 static void DeleteIfClosed(Handle* handle) { | 938 static void DeleteIfClosed(Handle* handle) { |
795 if (handle->IsClosed()) { | 939 if (handle->IsClosed()) { |
796 Dart_Port port = handle->port(); | 940 Dart_Port port = handle->port(); |
797 delete handle; | 941 delete handle; |
798 DartUtils::PostInt32(port, 1 << kDestroyedEvent); | 942 DartUtils::PostInt32(port, 1 << kDestroyedEvent); |
799 } | 943 } |
800 } | 944 } |
801 | 945 |
802 | 946 |
803 void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) { | 947 void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 // for read. | 995 // for read. |
852 if ((msg->data & (1 << kInEvent)) != 0) { | 996 if ((msg->data & (1 << kInEvent)) != 0) { |
853 if (handle->Available() > 0) { | 997 if (handle->Available() > 0) { |
854 int event_mask = (1 << kInEvent); | 998 int event_mask = (1 << kInEvent); |
855 handle->set_mask(handle->mask() & ~event_mask); | 999 handle->set_mask(handle->mask() & ~event_mask); |
856 DartUtils::PostInt32(handle->port(), event_mask); | 1000 DartUtils::PostInt32(handle->port(), event_mask); |
857 } else if (handle->IsClosedRead()) { | 1001 } else if (handle->IsClosedRead()) { |
858 int event_mask = (1 << kCloseEvent); | 1002 int event_mask = (1 << kCloseEvent); |
859 DartUtils::PostInt32(handle->port(), event_mask); | 1003 DartUtils::PostInt32(handle->port(), event_mask); |
860 } else if (!handle->HasPendingRead()) { | 1004 } else if (!handle->HasPendingRead()) { |
861 handle->IssueRead(); | 1005 if (handle->is_datagram_socket()) { |
| 1006 handle->IssueRecvFrom(); |
| 1007 } else { |
| 1008 handle->IssueRead(); |
| 1009 } |
862 } | 1010 } |
863 } | 1011 } |
864 | 1012 |
865 // If out events (can write events) have been requested, and there | 1013 // If out events (can write events) have been requested, and there |
866 // are no pending writes, post an out event immediately. | 1014 // are no pending writes, post an out event immediately. |
867 if ((msg->data & (1 << kOutEvent)) != 0) { | 1015 if ((msg->data & (1 << kOutEvent)) != 0) { |
868 if (!handle->HasPendingWrite()) { | 1016 if (!handle->HasPendingWrite()) { |
869 int event_mask = (1 << kOutEvent); | 1017 int event_mask = (1 << kOutEvent); |
870 handle->set_mask(handle->mask() & ~event_mask); | 1018 handle->set_mask(handle->mask() & ~event_mask); |
871 DartUtils::PostInt32(handle->port(), event_mask); | 1019 DartUtils::PostInt32(handle->port(), event_mask); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 HandleClosed(handle); | 1094 HandleClosed(handle); |
947 } else { | 1095 } else { |
948 HandleError(handle); | 1096 HandleError(handle); |
949 } | 1097 } |
950 } | 1098 } |
951 | 1099 |
952 DeleteIfClosed(handle); | 1100 DeleteIfClosed(handle); |
953 } | 1101 } |
954 | 1102 |
955 | 1103 |
| 1104 void EventHandlerImplementation::HandleRecvFrom(Handle* handle, |
| 1105 int bytes, |
| 1106 OverlappedBuffer* buffer) { |
| 1107 ASSERT(handle->is_datagram_socket()); |
| 1108 buffer->set_data_length(bytes); |
| 1109 handle->ReadComplete(buffer); |
| 1110 if (!handle->IsClosing()) { |
| 1111 int event_mask = 1 << kInEvent; |
| 1112 if ((handle->mask() & event_mask) != 0) { |
| 1113 DartUtils::PostInt32(handle->port(), event_mask); |
| 1114 } |
| 1115 } |
| 1116 |
| 1117 DeleteIfClosed(handle); |
| 1118 } |
| 1119 |
| 1120 |
956 void EventHandlerImplementation::HandleWrite(Handle* handle, | 1121 void EventHandlerImplementation::HandleWrite(Handle* handle, |
957 int bytes, | 1122 int bytes, |
958 OverlappedBuffer* buffer) { | 1123 OverlappedBuffer* buffer) { |
959 handle->WriteComplete(buffer); | 1124 handle->WriteComplete(buffer); |
960 | 1125 |
961 if (bytes > 0) { | 1126 if (bytes > 0) { |
962 if (!handle->IsError() && !handle->IsClosing()) { | 1127 if (!handle->IsError() && !handle->IsClosing()) { |
963 int event_mask = 1 << kOutEvent; | 1128 int event_mask = 1 << kOutEvent; |
964 if ((handle->mask() & event_mask) != 0) { | 1129 if ((handle->mask() & event_mask) != 0) { |
965 DartUtils::PostInt32(handle->port(), event_mask); | 1130 DartUtils::PostInt32(handle->port(), event_mask); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 case OverlappedBuffer::kAccept: { | 1162 case OverlappedBuffer::kAccept: { |
998 ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(key); | 1163 ListenSocket* listen_socket = reinterpret_cast<ListenSocket*>(key); |
999 HandleAccept(listen_socket, buffer); | 1164 HandleAccept(listen_socket, buffer); |
1000 break; | 1165 break; |
1001 } | 1166 } |
1002 case OverlappedBuffer::kRead: { | 1167 case OverlappedBuffer::kRead: { |
1003 Handle* handle = reinterpret_cast<Handle*>(key); | 1168 Handle* handle = reinterpret_cast<Handle*>(key); |
1004 HandleRead(handle, bytes, buffer); | 1169 HandleRead(handle, bytes, buffer); |
1005 break; | 1170 break; |
1006 } | 1171 } |
1007 case OverlappedBuffer::kWrite: { | 1172 case OverlappedBuffer::kRecvFrom: { |
| 1173 Handle* handle = reinterpret_cast<Handle*>(key); |
| 1174 HandleRecvFrom(handle, bytes, buffer); |
| 1175 break; |
| 1176 } |
| 1177 case OverlappedBuffer::kWrite: |
| 1178 case OverlappedBuffer::kSendTo: { |
1008 Handle* handle = reinterpret_cast<Handle*>(key); | 1179 Handle* handle = reinterpret_cast<Handle*>(key); |
1009 HandleWrite(handle, bytes, buffer); | 1180 HandleWrite(handle, bytes, buffer); |
1010 break; | 1181 break; |
1011 } | 1182 } |
1012 case OverlappedBuffer::kDisconnect: { | 1183 case OverlappedBuffer::kDisconnect: { |
1013 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(key); | 1184 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(key); |
1014 HandleDisconnect(client_socket, bytes, buffer); | 1185 HandleDisconnect(client_socket, bytes, buffer); |
1015 break; | 1186 break; |
1016 } | 1187 } |
1017 default: | 1188 default: |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 | 1303 |
1133 | 1304 |
1134 void EventHandlerImplementation::Shutdown() { | 1305 void EventHandlerImplementation::Shutdown() { |
1135 SendData(kShutdownId, 0, 0); | 1306 SendData(kShutdownId, 0, 0); |
1136 } | 1307 } |
1137 | 1308 |
1138 } // namespace bin | 1309 } // namespace bin |
1139 } // namespace dart | 1310 } // namespace dart |
1140 | 1311 |
1141 #endif // defined(TARGET_OS_WINDOWS) | 1312 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |