| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 <process.h> // NOLINT | 10 #include <process.h> // NOLINT |
| 11 #include <winsock2.h> // NOLINT | 11 #include <winsock2.h> // NOLINT |
| 12 #include <ws2tcpip.h> // NOLINT | 12 #include <ws2tcpip.h> // NOLINT |
| 13 #include <mswsock.h> // NOLINT | 13 #include <mswsock.h> // NOLINT |
| 14 | 14 |
| 15 #include "bin/builtin.h" | 15 #include "bin/builtin.h" |
| 16 #include "bin/dartutils.h" | 16 #include "bin/dartutils.h" |
| 17 #include "bin/log.h" | 17 #include "bin/log.h" |
| 18 #include "bin/socket.h" | 18 #include "bin/socket.h" |
| 19 #include "bin/utils.h" | 19 #include "bin/utils.h" |
| 20 #include "platform/thread.h" | 20 #include "platform/thread.h" |
| 21 | 21 |
| 22 | 22 |
| 23 namespace dart { | 23 namespace dart { |
| 24 namespace bin { | 24 namespace bin { |
| 25 | 25 |
| 26 static const int kBufferSize = 32 * 1024; | 26 static const int kBufferSize = 64 * 1024; |
| 27 static const int kStdioBufferSize = 16 * 1024; |
| 27 | 28 |
| 28 static const int kInfinityTimeout = -1; | 29 static const int kInfinityTimeout = -1; |
| 29 static const int kTimeoutId = -1; | 30 static const int kTimeoutId = -1; |
| 30 static const int kShutdownId = -2; | 31 static const int kShutdownId = -2; |
| 31 | 32 |
| 32 IOBuffer* IOBuffer::AllocateBuffer(int buffer_size, Operation operation) { | 33 IOBuffer* IOBuffer::AllocateBuffer(int buffer_size, Operation operation) { |
| 33 IOBuffer* buffer = new(buffer_size) IOBuffer(buffer_size, operation); | 34 IOBuffer* buffer = new(buffer_size) IOBuffer(buffer_size, operation); |
| 34 return buffer; | 35 return buffer; |
| 35 } | 36 } |
| 36 | 37 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 206 |
| 206 static unsigned int __stdcall ReadFileThread(void* args) { | 207 static unsigned int __stdcall ReadFileThread(void* args) { |
| 207 Handle* handle = reinterpret_cast<Handle*>(args); | 208 Handle* handle = reinterpret_cast<Handle*>(args); |
| 208 handle->ReadSyncCompleteAsync(); | 209 handle->ReadSyncCompleteAsync(); |
| 209 return 0; | 210 return 0; |
| 210 } | 211 } |
| 211 | 212 |
| 212 | 213 |
| 213 void Handle::ReadSyncCompleteAsync() { | 214 void Handle::ReadSyncCompleteAsync() { |
| 214 ASSERT(pending_read_ != NULL); | 215 ASSERT(pending_read_ != NULL); |
| 216 ASSERT(pending_read_->GetBufferSize() >= kStdioBufferSize); |
| 217 |
| 218 DWORD buffer_size = pending_read_->GetBufferSize(); |
| 219 if (GetFileType(handle_) == FILE_TYPE_CHAR) { |
| 220 buffer_size = kStdioBufferSize; |
| 221 } |
| 215 DWORD bytes_read = 0; | 222 DWORD bytes_read = 0; |
| 216 BOOL ok = ReadFile(handle_, | 223 BOOL ok = ReadFile(handle_, |
| 217 pending_read_->GetBufferStart(), | 224 pending_read_->GetBufferStart(), |
| 218 pending_read_->GetBufferSize(), | 225 buffer_size, |
| 219 &bytes_read, | 226 &bytes_read, |
| 220 NULL); | 227 NULL); |
| 221 if (!ok) { | 228 if (!ok) { |
| 222 if (GetLastError() != ERROR_BROKEN_PIPE) { | 229 if (GetLastError() != ERROR_BROKEN_PIPE) { |
| 223 Log::PrintErr("ReadFile failed %d\n", GetLastError()); | 230 Log::PrintErr("ReadFile failed %d\n", GetLastError()); |
| 224 } | 231 } |
| 225 bytes_read = 0; | 232 bytes_read = 0; |
| 226 } | 233 } |
| 227 OVERLAPPED* overlapped = pending_read_->GetCleanOverlapped(); | 234 OVERLAPPED* overlapped = pending_read_->GetCleanOverlapped(); |
| 228 ok = PostQueuedCompletionStatus(event_handler_->completion_port(), | 235 ok = PostQueuedCompletionStatus(event_handler_->completion_port(), |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 | 998 |
| 992 | 999 |
| 993 void EventHandlerImplementation::Shutdown() { | 1000 void EventHandlerImplementation::Shutdown() { |
| 994 SendData(kShutdownId, 0, 0); | 1001 SendData(kShutdownId, 0, 0); |
| 995 } | 1002 } |
| 996 | 1003 |
| 997 } // namespace bin | 1004 } // namespace bin |
| 998 } // namespace dart | 1005 } // namespace dart |
| 999 | 1006 |
| 1000 #endif // defined(TARGET_OS_WINDOWS) | 1007 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |