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

Side by Side Diff: runtime/bin/socket.h

Issue 2228503007: Fixes memory leaks in the eventhandler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 4 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
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | runtime/bin/socket.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #ifndef BIN_SOCKET_H_ 5 #ifndef BIN_SOCKET_H_
6 #define BIN_SOCKET_H_ 6 #define BIN_SOCKET_H_
7 7
8 #if defined(DART_IO_DISABLED) 8 #if defined(DART_IO_DISABLED)
9 #error "socket.h can only be included on builds with IO enabled" 9 #error "socket.h can only be included on builds with IO enabled"
10 #endif 10 #endif
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 static void Initialize(); 395 static void Initialize();
396 396
397 static ListeningSocketRegistry *Instance(); 397 static ListeningSocketRegistry *Instance();
398 398
399 static void Cleanup(); 399 static void Cleanup();
400 400
401 401
402 ListeningSocketRegistry() : mutex_(new Mutex()) {} 402 ListeningSocketRegistry() : mutex_(new Mutex()) {}
403 403
404 ~ListeningSocketRegistry() { 404 ~ListeningSocketRegistry() {
405 CloseAllSafe();
405 delete mutex_; 406 delete mutex_;
406 mutex_ = NULL; 407 mutex_ = NULL;
407 } 408 }
408 409
409 // This function should be called from a dart runtime call in order to create 410 // This function should be called from a dart runtime call in order to create
410 // a new (potentially shared) socket. 411 // a new (potentially shared) socket.
411 Dart_Handle CreateBindListen(Dart_Handle socket_object, 412 Dart_Handle CreateBindListen(Dart_Handle socket_object,
412 RawAddr addr, 413 RawAddr addr,
413 intptr_t backlog, 414 intptr_t backlog,
414 bool v6_only, 415 bool v6_only,
(...skipping 15 matching lines...) Expand all
430 OSSocket *findOSSocketWithAddress(OSSocket *current, const RawAddr& addr) { 431 OSSocket *findOSSocketWithAddress(OSSocket *current, const RawAddr& addr) {
431 while (current != NULL) { 432 while (current != NULL) {
432 if (SocketAddress::AreAddressesEqual(current->address, addr)) { 433 if (SocketAddress::AreAddressesEqual(current->address, addr)) {
433 return current; 434 return current;
434 } 435 }
435 current = current->next; 436 current = current->next;
436 } 437 }
437 return NULL; 438 return NULL;
438 } 439 }
439 440
441 bool CloseOneSafe(OSSocket* os_socket);
442 void CloseAllSafe();
443
444 // TODO(zra): Replace std::map with the HashMap in platform/hashmap.h.
440 std::map<intptr_t, OSSocket*> sockets_by_port_; 445 std::map<intptr_t, OSSocket*> sockets_by_port_;
441 std::map<intptr_t, OSSocket*> sockets_by_fd_; 446 std::map<intptr_t, OSSocket*> sockets_by_fd_;
442 Mutex *mutex_; 447 Mutex *mutex_;
443 448
444 typedef std::map<intptr_t, OSSocket*>::iterator SocketsIterator; 449 typedef std::map<intptr_t, OSSocket*>::iterator SocketsIterator;
445 450
446 private: 451 private:
447 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry); 452 DISALLOW_COPY_AND_ASSIGN(ListeningSocketRegistry);
448 }; 453 };
449 454
450 } // namespace bin 455 } // namespace bin
451 } // namespace dart 456 } // namespace dart
452 457
453 #endif // BIN_SOCKET_H_ 458 #endif // BIN_SOCKET_H_
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | runtime/bin/socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698