| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 | 173 |
| 174 void Handle::Close() { | 174 void Handle::Close() { |
| 175 ScopedLock lock(this); | 175 ScopedLock lock(this); |
| 176 if (!IsClosing()) { | 176 if (!IsClosing()) { |
| 177 // Close the socket and set the closing state. This close method can be | 177 // Close the socket and set the closing state. This close method can be |
| 178 // called again if this socket has pending IO operations in flight. | 178 // called again if this socket has pending IO operations in flight. |
| 179 ASSERT(handle_ != INVALID_HANDLE_VALUE); | |
| 180 MarkClosing(); | 179 MarkClosing(); |
| 181 // Perform handle type specific closing. | 180 // Perform handle type specific closing. |
| 182 DoClose(); | 181 DoClose(); |
| 183 } | 182 } |
| 183 ASSERT(IsHandleClosed()); |
| 184 } | 184 } |
| 185 | 185 |
| 186 | 186 |
| 187 void Handle::DoClose() { | 187 void Handle::DoClose() { |
| 188 CloseHandle(handle_); | 188 if (!IsHandleClosed()) { |
| 189 handle_ = INVALID_HANDLE_VALUE; | 189 CloseHandle(handle_); |
| 190 handle_ = INVALID_HANDLE_VALUE; |
| 191 } |
| 190 } | 192 } |
| 191 | 193 |
| 192 | 194 |
| 193 bool Handle::HasPendingRead() { | 195 bool Handle::HasPendingRead() { |
| 194 ScopedLock lock(this); | 196 ScopedLock lock(this); |
| 195 return pending_read_ != NULL; | 197 return pending_read_ != NULL; |
| 196 } | 198 } |
| 197 | 199 |
| 198 | 200 |
| 199 bool Handle::HasPendingWrite() { | 201 bool Handle::HasPendingWrite() { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 419 } |
| 418 | 420 |
| 419 | 421 |
| 420 void DirectoryWatchHandle::Stop() { | 422 void DirectoryWatchHandle::Stop() { |
| 421 ScopedLock lock(this); | 423 ScopedLock lock(this); |
| 422 // Stop the outstanding read, so we can close the handle. | 424 // Stop the outstanding read, so we can close the handle. |
| 423 | 425 |
| 424 if (pending_read_ != NULL) { | 426 if (pending_read_ != NULL) { |
| 425 CancelIoEx(handle(), pending_read_->GetCleanOverlapped()); | 427 CancelIoEx(handle(), pending_read_->GetCleanOverlapped()); |
| 426 // Don't dispose of the buffer, as it will still complete (with length 0). | 428 // Don't dispose of the buffer, as it will still complete (with length 0). |
| 427 pending_read_ = NULL; | |
| 428 } | 429 } |
| 429 | 430 |
| 430 CloseHandle(handle()); | 431 DoClose(); |
| 431 handle_ = (INVALID_HANDLE_VALUE); | |
| 432 } | 432 } |
| 433 | 433 |
| 434 | 434 |
| 435 void SocketHandle::HandleIssueError() { | 435 void SocketHandle::HandleIssueError() { |
| 436 int error = WSAGetLastError(); | 436 int error = WSAGetLastError(); |
| 437 if (error == WSAECONNRESET) { | 437 if (error == WSAECONNRESET) { |
| 438 HandleClosed(this); | 438 HandleClosed(this); |
| 439 } else { | 439 } else { |
| 440 HandleError(this); | 440 HandleError(this); |
| 441 } | 441 } |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 | 1363 |
| 1364 | 1364 |
| 1365 void EventHandlerImplementation::Shutdown() { | 1365 void EventHandlerImplementation::Shutdown() { |
| 1366 SendData(kShutdownId, 0, 0); | 1366 SendData(kShutdownId, 0, 0); |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 } // namespace bin | 1369 } // namespace bin |
| 1370 } // namespace dart | 1370 } // namespace dart |
| 1371 | 1371 |
| 1372 #endif // defined(TARGET_OS_WINDOWS) | 1372 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |