Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: dart/runtime/bin/eventhandler_win.cc

Issue 913753002: Reland "Introduce optional 'bool shared' parameter to ServerSocket.bind() ..." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/runtime/bin/eventhandler_macos.cc ('k') | dart/runtime/bin/io_natives.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « dart/runtime/bin/eventhandler_macos.cc ('k') | dart/runtime/bin/io_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698