| Index: dart/runtime/bin/eventhandler_win.cc
|
| diff --git a/dart/runtime/bin/eventhandler_win.cc b/dart/runtime/bin/eventhandler_win.cc
|
| index 8dba9640e64e48c32fd497f8933ac0aa4ec2f74d..e5d2263e942be120a21d280175653e18d8883702 100644
|
| --- a/dart/runtime/bin/eventhandler_win.cc
|
| +++ b/dart/runtime/bin/eventhandler_win.cc
|
| @@ -1018,12 +1018,17 @@ void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) {
|
| listen_socket->SetPortAndMask(msg->dart_port, events);
|
| TryDispatchingPendingAccepts(listen_socket);
|
| } else if (IS_COMMAND(msg->data, kCloseCommand)) {
|
| - handle->SetPortAndMask(msg->dart_port, 0);
|
| - if (handle->Mask() == 0) {
|
| - // TODO(dart:io): This assumes that all sockets listen before we
|
| - // close.
|
| - // This needs to be synchronized with a global datastructure.
|
| - handle->Close();
|
| + listen_socket->SetPortAndMask(msg->dart_port, 0);
|
| + // We only close the socket file descriptor from the operating
|
| + // system if there are no other dart socket objects which
|
| + // are listening on the same (address, port) combination.
|
| + ListeningSocketRegistry *registry =
|
| + ListeningSocketRegistry::Instance();
|
| + MutexLocker locker(registry->mutex());
|
| + if (registry->CloseSafe(reinterpret_cast<intptr_t>(listen_socket))) {
|
| + ASSERT(listen_socket->Mask() == 0);
|
| + listen_socket->Close();
|
| + DeleteIfClosed(handle);
|
| }
|
| } else {
|
| UNREACHABLE();
|
| @@ -1093,8 +1098,8 @@ void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) {
|
| } else {
|
| UNREACHABLE();
|
| }
|
| + DeleteIfClosed(handle);
|
| }
|
| - DeleteIfClosed(handle);
|
| }
|
| }
|
|
|
|
|