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

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

Issue 2760293002: [dart:io] Adds a finalizer to _NativeSocket to avoid socket leaks (Closed)
Patch Set: Address comments Created 3 years, 8 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.cc ('k') | runtime/bin/socket_fuchsia.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 #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_ANDROID) 8 #if defined(HOST_OS_ANDROID)
9 9
10 #include "bin/socket.h" 10 #include "bin/socket.h"
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 37
38 38
39 bool Socket::FormatNumericAddress(const RawAddr& addr, char* address, int len) { 39 bool Socket::FormatNumericAddress(const RawAddr& addr, char* address, int len) {
40 socklen_t salen = SocketAddress::GetAddrLength(addr); 40 socklen_t salen = SocketAddress::GetAddrLength(addr);
41 return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL, 41 return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL,
42 0, NI_NUMERICHOST)) == 0); 42 0, NI_NUMERICHOST)) == 0);
43 } 43 }
44 44
45 45
46 Socket::Socket(intptr_t fd)
47 : ReferenceCounted(), fd_(fd), port_(ILLEGAL_PORT) {}
48
49
50 void Socket::SetClosedFd() {
51 fd_ = kClosedFd;
52 }
53
54
46 bool Socket::Initialize() { 55 bool Socket::Initialize() {
47 // Nothing to do on Android. 56 // Nothing to do on Android.
48 return true; 57 return true;
49 } 58 }
50 59
51 60
52 static intptr_t Create(const RawAddr& addr) { 61 static intptr_t Create(const RawAddr& addr) {
53 intptr_t fd; 62 intptr_t fd;
54 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0)); 63 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0));
55 if (fd < 0) { 64 if (fd < 0) {
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 return NO_RETRY_EXPECTED(setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, 585 return NO_RETRY_EXPECTED(setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq,
577 sizeof(mreq))) == 0; 586 sizeof(mreq))) == 0;
578 } 587 }
579 588
580 } // namespace bin 589 } // namespace bin
581 } // namespace dart 590 } // namespace dart
582 591
583 #endif // defined(HOST_OS_ANDROID) 592 #endif // defined(HOST_OS_ANDROID)
584 593
585 #endif // !defined(DART_IO_DISABLED) 594 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/bin/socket_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698