Chromium Code Reviews| Index: runtime/bin/eventhandler_win.cc |
| diff --git a/runtime/bin/eventhandler_win.cc b/runtime/bin/eventhandler_win.cc |
| index 332f80f8731b815081b89952e165b2d3fd6cb7d6..831424b9f96557f639521a22a04ae4772936c063 100644 |
| --- a/runtime/bin/eventhandler_win.cc |
| +++ b/runtime/bin/eventhandler_win.cc |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| @@ -324,7 +324,7 @@ void FileHandle::EnsureInitialized(EventHandlerImplementation* event_handler) { |
| bool FileHandle::IsClosed() { |
| - return false; |
| + return IsClosing(); |
| } |
| @@ -573,7 +573,7 @@ void ClientSocket::Shutdown(int how) { |
| void ClientSocket::DoClose() { |
| - // Always do a suhtdown before initiating a disconnect. |
| + // Always do a shutdown before initiating a disconnect. |
| shutdown(socket(), SD_BOTH); |
| IssueDisconnect(); |
| } |
| @@ -630,12 +630,14 @@ bool ClientSocket::IssueWrite() { |
| void ClientSocket::IssueDisconnect() { |
| + Dart_Port p = port(); |
| IOBuffer* buffer = IOBuffer::AllocateDisconnectBuffer(); |
| BOOL ok = DisconnectEx_( |
| socket(), buffer->GetCleanOverlapped(), TF_REUSE_SOCKET, 0); |
| if (!ok && WSAGetLastError() != WSA_IO_PENDING) { |
| DisconnectComplete(buffer); |
| } |
| + if (p != ILLEGAL_PORT) DartUtils::PostInt32(p, 1 << kDestroyedEvent); |
| } |
| @@ -666,6 +668,15 @@ bool ClientSocket::IsClosed() { |
| } |
| +static void DeleteIfClosed(Handle* handle) { |
| + if (handle->IsClosed()) { |
| + Dart_Port port = handle->port(); |
| + delete handle; |
| + DartUtils::PostInt32(port, 1 << kDestroyedEvent); |
| + } |
| +} |
| + |
| + |
| void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) { |
| if (msg->id == kTimeoutId) { |
| // Change of timeout request. Just set the new timeout and port as the |
| @@ -756,6 +767,7 @@ void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) { |
| } |
| if ((msg->data & (1 << kCloseCommand)) != 0) { |
| + handle->SetPortAndMask(msg->dart_port, msg->data); |
| handle->Close(); |
| if (handle->IsClosed()) { |
| delete_handle = true; |
|
kustermann
2013/07/19 11:59:18
remove this.
Anders Johnsen
2013/07/19 13:25:58
Done.
|
| @@ -763,7 +775,7 @@ void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) { |
| } |
| } |
| if (delete_handle) { |
| - delete handle; |
| + DeleteIfClosed(handle); |
|
kustermann
2013/07/19 11:59:18
Remove the condition.
Anders Johnsen
2013/07/19 13:25:58
Done.
|
| } |
| } |
| } |
| @@ -780,9 +792,7 @@ void EventHandlerImplementation::HandleAccept(ListenSocket* listen_socket, |
| } |
| } |
| - if (listen_socket->IsClosed()) { |
| - delete listen_socket; |
| - } |
| + DeleteIfClosed(listen_socket); |
| } |
| @@ -825,9 +835,7 @@ void EventHandlerImplementation::HandleRead(Handle* handle, |
| } |
| } |
| - if (handle->IsClosed()) { |
| - delete handle; |
| - } |
| + DeleteIfClosed(handle); |
| } |
| @@ -849,9 +857,7 @@ void EventHandlerImplementation::HandleWrite(Handle* handle, |
| HandleError(handle); |
| } |
| - if (handle->IsClosed()) { |
| - delete handle; |
| - } |
| + DeleteIfClosed(handle); |
| } |