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

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

Issue 15293002: Fix socket leak in HttpServer, when the connection is closed while receiving data. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
« no previous file with comments | « sdk/lib/io/http_parser.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
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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 new Timer(const Duration(milliseconds: 200), () { 104 new Timer(const Duration(milliseconds: 200), () {
105 subscription.cancel(); 105 subscription.cancel();
106 check(); 106 check();
107 }); 107 });
108 }); 108 });
109 } 109 }
110 }); 110 });
111 } 111 }
112 112
113 113
114 void testClientCloseWhileSendingRequest(int connections) {
115 HttpServer.bind("127.0.0.1", 0).then((server) {
116 int errors = 0;
117 server.listen((request) {
118 request.listen((_) {}, onError: (e) { errors++; });
119 });
120 var client = new HttpClient();
121 for (int i = 0; i < connections; i++) {
122 client.post("127.0.0.1", server.port, "/")
123 .then((request) {
124 request.contentLength = 110;
125 request.write("0123456789");
126 return request.close();
127 })
128 .catchError((_) {});
129 }
130 new Timer.periodic(const Duration(milliseconds: 100), (t) {
131 if (errors == connections && server.connectionsInfo().total == 0) {
132 t.cancel();
133 server.close();
134 }
135 });
136 });
137 }
138
139
114 void main() { 140 void main() {
115 testClientAndServerCloseNoListen(10); 141 testClientAndServerCloseNoListen(10);
116 testClientCloseServerListen(10); 142 testClientCloseServerListen(10);
117 testClientCloseSendingResponse(10); 143 testClientCloseSendingResponse(10);
144 testClientCloseWhileSendingRequest(10);
118 } 145 }
119 146
OLDNEW
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698