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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
8 #if defined(HOST_OS_WINDOWS) | 8 #if defined(HOST_OS_WINDOWS) |
9 | 9 |
10 #include "bin/eventhandler.h" | 10 #include "bin/eventhandler.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 | 532 |
533 | 533 |
534 void ListenSocket::AcceptComplete(OverlappedBuffer* buffer, | 534 void ListenSocket::AcceptComplete(OverlappedBuffer* buffer, |
535 HANDLE completion_port) { | 535 HANDLE completion_port) { |
536 MonitorLocker ml(monitor_); | 536 MonitorLocker ml(monitor_); |
537 if (!IsClosing()) { | 537 if (!IsClosing()) { |
538 // Update the accepted socket to support the full range of API calls. | 538 // Update the accepted socket to support the full range of API calls. |
539 SOCKET s = socket(); | 539 SOCKET s = socket(); |
540 int rc = setsockopt(buffer->client(), SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, | 540 int rc = setsockopt(buffer->client(), SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, |
541 reinterpret_cast<char*>(&s), sizeof(s)); | 541 reinterpret_cast<char*>(&s), sizeof(s)); |
542 if (rc == NO_ERROR) { | 542 if (rc == MX_OK) { |
zra
2017/06/09 19:24:25
This is a Windows file =)
| |
543 // Insert the accepted socket into the list. | 543 // Insert the accepted socket into the list. |
544 ClientSocket* client_socket = new ClientSocket(buffer->client()); | 544 ClientSocket* client_socket = new ClientSocket(buffer->client()); |
545 client_socket->mark_connected(); | 545 client_socket->mark_connected(); |
546 client_socket->CreateCompletionPort(completion_port); | 546 client_socket->CreateCompletionPort(completion_port); |
547 if (accepted_head_ == NULL) { | 547 if (accepted_head_ == NULL) { |
548 accepted_head_ = client_socket; | 548 accepted_head_ = client_socket; |
549 accepted_tail_ = client_socket; | 549 accepted_tail_ = client_socket; |
550 } else { | 550 } else { |
551 ASSERT(accepted_tail_ != NULL); | 551 ASSERT(accepted_tail_ != NULL); |
552 accepted_tail_->set_next(client_socket); | 552 accepted_tail_->set_next(client_socket); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
932 ASSERT(pending_read_ == NULL); | 932 ASSERT(pending_read_ == NULL); |
933 | 933 |
934 // TODO(sgjesse): Use a MTU value here. Only the loopback adapter can | 934 // TODO(sgjesse): Use a MTU value here. Only the loopback adapter can |
935 // handle 64k datagrams. | 935 // handle 64k datagrams. |
936 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(65536); | 936 OverlappedBuffer* buffer = OverlappedBuffer::AllocateReadBuffer(65536); |
937 | 937 |
938 DWORD flags; | 938 DWORD flags; |
939 flags = 0; | 939 flags = 0; |
940 int rc = WSARecv(socket(), buffer->GetWASBUF(), 1, NULL, &flags, | 940 int rc = WSARecv(socket(), buffer->GetWASBUF(), 1, NULL, &flags, |
941 buffer->GetCleanOverlapped(), NULL); | 941 buffer->GetCleanOverlapped(), NULL); |
942 if ((rc == NO_ERROR) || (WSAGetLastError() == WSA_IO_PENDING)) { | 942 if ((rc == MX_OK) || (WSAGetLastError() == WSA_IO_PENDING)) { |
943 pending_read_ = buffer; | 943 pending_read_ = buffer; |
944 return true; | 944 return true; |
945 } | 945 } |
946 OverlappedBuffer::DisposeBuffer(buffer); | 946 OverlappedBuffer::DisposeBuffer(buffer); |
947 pending_read_ = NULL; | 947 pending_read_ = NULL; |
948 HandleIssueError(); | 948 HandleIssueError(); |
949 return false; | 949 return false; |
950 } | 950 } |
951 | 951 |
952 | 952 |
953 bool ClientSocket::IssueWrite() { | 953 bool ClientSocket::IssueWrite() { |
954 MonitorLocker ml(monitor_); | 954 MonitorLocker ml(monitor_); |
955 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); | 955 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
956 ASSERT(pending_write_ != NULL); | 956 ASSERT(pending_write_ != NULL); |
957 ASSERT(pending_write_->operation() == OverlappedBuffer::kWrite); | 957 ASSERT(pending_write_->operation() == OverlappedBuffer::kWrite); |
958 | 958 |
959 int rc = WSASend(socket(), pending_write_->GetWASBUF(), 1, NULL, 0, | 959 int rc = WSASend(socket(), pending_write_->GetWASBUF(), 1, NULL, 0, |
960 pending_write_->GetCleanOverlapped(), NULL); | 960 pending_write_->GetCleanOverlapped(), NULL); |
961 if ((rc == NO_ERROR) || (WSAGetLastError() == WSA_IO_PENDING)) { | 961 if ((rc == MX_OK) || (WSAGetLastError() == WSA_IO_PENDING)) { |
962 return true; | 962 return true; |
963 } | 963 } |
964 OverlappedBuffer::DisposeBuffer(pending_write_); | 964 OverlappedBuffer::DisposeBuffer(pending_write_); |
965 pending_write_ = NULL; | 965 pending_write_ = NULL; |
966 HandleIssueError(); | 966 HandleIssueError(); |
967 return false; | 967 return false; |
968 } | 968 } |
969 | 969 |
970 | 970 |
971 void ClientSocket::IssueDisconnect() { | 971 void ClientSocket::IssueDisconnect() { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1038 | 1038 |
1039 | 1039 |
1040 bool DatagramSocket::IssueSendTo(struct sockaddr* sa, socklen_t sa_len) { | 1040 bool DatagramSocket::IssueSendTo(struct sockaddr* sa, socklen_t sa_len) { |
1041 MonitorLocker ml(monitor_); | 1041 MonitorLocker ml(monitor_); |
1042 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); | 1042 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
1043 ASSERT(pending_write_ != NULL); | 1043 ASSERT(pending_write_ != NULL); |
1044 ASSERT(pending_write_->operation() == OverlappedBuffer::kSendTo); | 1044 ASSERT(pending_write_->operation() == OverlappedBuffer::kSendTo); |
1045 | 1045 |
1046 int rc = WSASendTo(socket(), pending_write_->GetWASBUF(), 1, NULL, 0, sa, | 1046 int rc = WSASendTo(socket(), pending_write_->GetWASBUF(), 1, NULL, 0, sa, |
1047 sa_len, pending_write_->GetCleanOverlapped(), NULL); | 1047 sa_len, pending_write_->GetCleanOverlapped(), NULL); |
1048 if ((rc == NO_ERROR) || (WSAGetLastError() == WSA_IO_PENDING)) { | 1048 if ((rc == MX_OK) || (WSAGetLastError() == WSA_IO_PENDING)) { |
1049 return true; | 1049 return true; |
1050 } | 1050 } |
1051 OverlappedBuffer::DisposeBuffer(pending_write_); | 1051 OverlappedBuffer::DisposeBuffer(pending_write_); |
1052 pending_write_ = NULL; | 1052 pending_write_ = NULL; |
1053 HandleIssueError(); | 1053 HandleIssueError(); |
1054 return false; | 1054 return false; |
1055 } | 1055 } |
1056 | 1056 |
1057 | 1057 |
1058 bool DatagramSocket::IssueRecvFrom() { | 1058 bool DatagramSocket::IssueRecvFrom() { |
1059 MonitorLocker ml(monitor_); | 1059 MonitorLocker ml(monitor_); |
1060 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); | 1060 ASSERT(completion_port_ != INVALID_HANDLE_VALUE); |
1061 ASSERT(pending_read_ == NULL); | 1061 ASSERT(pending_read_ == NULL); |
1062 | 1062 |
1063 OverlappedBuffer* buffer = | 1063 OverlappedBuffer* buffer = |
1064 OverlappedBuffer::AllocateRecvFromBuffer(kMaxUDPPackageLength); | 1064 OverlappedBuffer::AllocateRecvFromBuffer(kMaxUDPPackageLength); |
1065 | 1065 |
1066 DWORD flags; | 1066 DWORD flags; |
1067 flags = 0; | 1067 flags = 0; |
1068 int rc = WSARecvFrom(socket(), buffer->GetWASBUF(), 1, NULL, &flags, | 1068 int rc = WSARecvFrom(socket(), buffer->GetWASBUF(), 1, NULL, &flags, |
1069 buffer->from(), buffer->from_len_addr(), | 1069 buffer->from(), buffer->from_len_addr(), |
1070 buffer->GetCleanOverlapped(), NULL); | 1070 buffer->GetCleanOverlapped(), NULL); |
1071 if ((rc == NO_ERROR) || (WSAGetLastError() == WSA_IO_PENDING)) { | 1071 if ((rc == MX_OK) || (WSAGetLastError() == WSA_IO_PENDING)) { |
1072 pending_read_ = buffer; | 1072 pending_read_ = buffer; |
1073 return true; | 1073 return true; |
1074 } | 1074 } |
1075 OverlappedBuffer::DisposeBuffer(buffer); | 1075 OverlappedBuffer::DisposeBuffer(buffer); |
1076 pending_read_ = NULL; | 1076 pending_read_ = NULL; |
1077 HandleIssueError(); | 1077 HandleIssueError(); |
1078 return false; | 1078 return false; |
1079 } | 1079 } |
1080 | 1080 |
1081 | 1081 |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1579 void EventHandlerImplementation::Shutdown() { | 1579 void EventHandlerImplementation::Shutdown() { |
1580 SendData(kShutdownId, 0, 0); | 1580 SendData(kShutdownId, 0, 0); |
1581 } | 1581 } |
1582 | 1582 |
1583 } // namespace bin | 1583 } // namespace bin |
1584 } // namespace dart | 1584 } // namespace dart |
1585 | 1585 |
1586 #endif // defined(HOST_OS_WINDOWS) | 1586 #endif // defined(HOST_OS_WINDOWS) |
1587 | 1587 |
1588 #endif // !defined(DART_IO_DISABLED) | 1588 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |