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

Unified Diff: dart/runtime/bin/eventhandler_linux.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_android.cc ('k') | dart/runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/runtime/bin/eventhandler_linux.cc
diff --git a/dart/runtime/bin/eventhandler_linux.cc b/dart/runtime/bin/eventhandler_linux.cc
index 2037fccd6060a9e26837495c91a8b88ada263462..f28481f70daf280741dae324d887b8c4ad89d5d1 100644
--- a/dart/runtime/bin/eventhandler_linux.cc
+++ b/dart/runtime/bin/eventhandler_linux.cc
@@ -241,13 +241,15 @@ void EventHandlerImplementation::HandleInterruptFd() {
// 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();
- // TODO(dart:io): This assumes that all sockets listen before we
- // close.
- // This needs to be synchronized with a global datastructure.
- if (new_mask == 0) {
- socket_map_.Remove(
- GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
+ MutexLocker locker(registry->mutex());
+
+ if (registry->CloseSafe(fd)) {
+ ASSERT(new_mask == 0);
+ socket_map_.Remove(GetHashmapKeyFromFd(fd),
+ GetHashmapHashFromFd(fd));
di->Close();
delete di;
}
« no previous file with comments | « dart/runtime/bin/eventhandler_android.cc ('k') | dart/runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698