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

Side by Side Diff: tests/standalone/io/socket_finalizer_test.dart

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 | « tests/standalone/io/socket_bind_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4 //
5 // This test checks that sockets belonging to an isolate are properly cleaned up
6 // when the isolate shuts down abnormally. If the socket is not properly cleaned
7 // up, the test will time out.
8
9 import 'dart:async';
10 import 'dart:io';
11 import 'dart:isolate';
12
13 import "package:async_helper/async_helper.dart";
14 import "package:expect/expect.dart";
15
16 ConnectorIsolate(int port) async {
17 Socket socket = await Socket.connect("127.0.0.1", port);
18 socket.listen((_) {});
19 }
20
21 main() async {
22 asyncStart();
23 ServerSocket server = await ServerSocket.bind("127.0.0.1", 0);
24 Isolate isolate = await Isolate.spawn(ConnectorIsolate, server.port);
25 Completer<Null> completer = new Completer<Null>();
26 server.listen((Socket socket) {
27 socket.listen((_) {}, onDone: () {
28 print("Socket closed normally");
29 completer.complete(null);
30 socket.close();
31 }, onError: (e) {
32 Expect.fail("Socket error $e");
33 });
34 isolate.kill();
35 });
36 await completer.future;
37 await server.close();
38 asyncEnd();
39 }
OLDNEW
« no previous file with comments | « tests/standalone/io/socket_bind_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698