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

Side by Side Diff: dart/runtime/bin/eventhandler_macos.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
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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 #include "bin/eventhandler_macos.h" 9 #include "bin/eventhandler_macos.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 UpdateKQueueInstance(old_mask, di); 237 UpdateKQueueInstance(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());
Søren Gjesse 2015/02/11 08:51:05 nit: Formatting (number of empty lines) of this se
kustermann 2015/02/11 09:56:08 Done.
246 // close. 248 if (registry->CloseSafe(fd)) {
247 // This needs to be synchronized with a global datastructure. 249 ASSERT(new_mask == 0);
248 if (new_mask == 0) { 250 socket_map_.Remove(GetHashmapKeyFromFd(fd),
249 socket_map_.Remove( 251 GetHashmapHashFromFd(fd));
250 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
251 di->Close(); 252 di->Close();
252 delete di; 253 delete di;
253 } 254 }
254
255
256 } else { 255 } else {
257 ASSERT(new_mask == 0); 256 ASSERT(new_mask == 0);
258 socket_map_.Remove( 257 socket_map_.Remove(
259 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 258 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
260 di->Close(); 259 di->Close();
261 delete di; 260 delete di;
262 } 261 }
263 262
264 DartUtils::PostInt32(port, 1 << kDestroyedEvent); 263 DartUtils::PostInt32(port, 1 << kDestroyedEvent);
265 } else if (IS_COMMAND(msg[i].data, kReturnTokenCommand)) { 264 } else if (IS_COMMAND(msg[i].data, kReturnTokenCommand)) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 480
482 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 481 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
483 // The hashmap does not support keys with value 0. 482 // The hashmap does not support keys with value 0.
484 return dart::Utils::WordHash(fd + 1); 483 return dart::Utils::WordHash(fd + 1);
485 } 484 }
486 485
487 } // namespace bin 486 } // namespace bin
488 } // namespace dart 487 } // namespace dart
489 488
490 #endif // defined(TARGET_OS_MACOS) 489 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698