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

Side by Side Diff: runtime/bin/socket_fuchsia.cc

Issue 2760293002: [dart:io] Adds a finalizer to _NativeSocket to avoid socket leaks (Closed)
Patch Set: Address comments Created 3 years, 9 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/socket_android.cc ('k') | runtime/bin/socket_linux.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_FUCHSIA) 8 #if defined(HOST_OS_FUCHSIA)
9 9
10 #include "bin/socket.h" 10 #include "bin/socket.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 66
67 bool Socket::FormatNumericAddress(const RawAddr& addr, char* address, int len) { 67 bool Socket::FormatNumericAddress(const RawAddr& addr, char* address, int len) {
68 socklen_t salen = SocketAddress::GetAddrLength(addr); 68 socklen_t salen = SocketAddress::GetAddrLength(addr);
69 LOG_INFO("Socket::FormatNumericAddress: calling getnameinfo\n"); 69 LOG_INFO("Socket::FormatNumericAddress: calling getnameinfo\n");
70 return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL, 70 return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL,
71 0, NI_NUMERICHOST) == 0)); 71 0, NI_NUMERICHOST) == 0));
72 } 72 }
73 73
74 74
75 Socket::Socket(intptr_t fd)
76 : ReferenceCounted(), fd_(fd), port_(ILLEGAL_PORT) {}
77
78
79 void Socket::SetClosedFd() {
80 fd_ = kClosedFd;
81 }
82
83
75 bool Socket::Initialize() { 84 bool Socket::Initialize() {
76 // Nothing to do on Fuchsia. 85 // Nothing to do on Fuchsia.
77 return true; 86 return true;
78 } 87 }
79 88
80 89
81 static intptr_t Create(const RawAddr& addr) { 90 static intptr_t Create(const RawAddr& addr) {
82 LOG_INFO("Create: calling socket(SOCK_STREAM)\n"); 91 LOG_INFO("Create: calling socket(SOCK_STREAM)\n");
83 intptr_t fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0)); 92 intptr_t fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0));
84 if (fd < 0) { 93 if (fd < 0) {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 UNIMPLEMENTED(); 539 UNIMPLEMENTED();
531 return false; 540 return false;
532 } 541 }
533 542
534 } // namespace bin 543 } // namespace bin
535 } // namespace dart 544 } // namespace dart
536 545
537 #endif // defined(HOST_OS_FUCHSIA) 546 #endif // defined(HOST_OS_FUCHSIA)
538 547
539 #endif // !defined(DART_IO_DISABLED) 548 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/socket_android.cc ('k') | runtime/bin/socket_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698