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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/runtime/bin/eventhandler_android.cc ('k') | dart/runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 #include "bin/eventhandler_linux.h" 9 #include "bin/eventhandler_linux.h"
10 10
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 Dart_Port port = msg[i].dart_port; 234 Dart_Port port = msg[i].dart_port;
235 di->RemovePort(port); 235 di->RemovePort(port);
236 intptr_t new_mask = di->Mask(); 236 intptr_t new_mask = di->Mask();
237 UpdateEpollInstance(old_mask, di); 237 UpdateEpollInstance(old_mask, di);
238 238
239 intptr_t fd = di->fd(); 239 intptr_t fd = di->fd();
240 if (di->IsListeningSocket()) { 240 if (di->IsListeningSocket()) {
241 // We only close the socket file descriptor from the operating 241 // We only close the socket file descriptor from the operating
242 // system if there are no other dart socket objects which 242 // system if there are no other dart socket objects which
243 // are listening on the same (address, port) combination. 243 // are listening on the same (address, port) combination.
244 ListeningSocketRegistry *registry =
245 ListeningSocketRegistry::Instance();
244 246
245 // TODO(dart:io): This assumes that all sockets listen before we 247 MutexLocker locker(registry->mutex());
246 // close. 248
247 // This needs to be synchronized with a global datastructure. 249 if (registry->CloseSafe(fd)) {
248 if (new_mask == 0) { 250 ASSERT(new_mask == 0);
249 socket_map_.Remove( 251 socket_map_.Remove(GetHashmapKeyFromFd(fd),
250 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 252 GetHashmapHashFromFd(fd));
251 di->Close(); 253 di->Close();
252 delete di; 254 delete di;
253 } 255 }
254 } else { 256 } else {
255 ASSERT(new_mask == 0); 257 ASSERT(new_mask == 0);
256 socket_map_.Remove( 258 socket_map_.Remove(
257 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 259 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
258 di->Close(); 260 di->Close();
259 delete di; 261 delete di;
260 } 262 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 413
412 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 414 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
413 // The hashmap does not support keys with value 0. 415 // The hashmap does not support keys with value 0.
414 return dart::Utils::WordHash(fd + 1); 416 return dart::Utils::WordHash(fd + 1);
415 } 417 }
416 418
417 } // namespace bin 419 } // namespace bin
418 } // namespace dart 420 } // namespace dart
419 421
420 #endif // defined(TARGET_OS_LINUX) 422 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« 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