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

Side by Side Diff: pkg/http_multi_server/lib/http_multi_server.dart

Issue 433593002: Remove the workaround for issue 19815 in http_multi_server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/http_multi_server/CHANGELOG.md ('k') | pkg/http_multi_server/lib/src/utils.dart » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library http_multi_server; 5 library http_multi_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'src/utils.dart'; 10 import 'src/utils.dart';
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 certificateName: certificateName, 92 certificateName: certificateName,
93 requestClientCertificate: requestClientCertificate)); 93 requestClientCertificate: requestClientCertificate));
94 } 94 }
95 95
96 /// A helper method for initializing loopback servers. 96 /// A helper method for initializing loopback servers.
97 /// 97 ///
98 /// [bind] should forward to either [HttpServer.bind] or 98 /// [bind] should forward to either [HttpServer.bind] or
99 /// [HttpServer.bindSecure]. 99 /// [HttpServer.bindSecure].
100 static Future<HttpServer> _loopback(int port, 100 static Future<HttpServer> _loopback(int port,
101 Future<HttpServer> bind(InternetAddress address, int port)) { 101 Future<HttpServer> bind(InternetAddress address, int port)) {
102 return bind(InternetAddress.LOOPBACK_IP_V4, port).then((v4Server) { 102 return Future.wait([
103 supportsIpV6,
104 bind(InternetAddress.LOOPBACK_IP_V4, port)
105 ]).then((results) {
106 var supportsIpV6 = results[0];
107 var v4Server = results[1];
108
109 if (!supportsIpV6) return v4Server;
110
103 // Reuse the IPv4 server's port so that if [port] is 0, both servers use 111 // Reuse the IPv4 server's port so that if [port] is 0, both servers use
104 // the same ephemeral port. 112 // the same ephemeral port.
105 return bind(InternetAddress.LOOPBACK_IP_V6, v4Server.port) 113 return bind(InternetAddress.LOOPBACK_IP_V6, v4Server.port)
106 .then((v6Server) => new HttpMultiServer([v4Server, v6Server])) 114 .then((v6Server) {
107 .catchError((error) { 115 return new HttpMultiServer([v4Server, v6Server]);
108 // If we fail to bind to IPv6, just use IPv4.
109 if (error is SocketException) return v4Server;
110 throw error;
111 }); 116 });
112 }); 117 });
113 } 118 }
114 119
115 Future close({bool force: false}) => 120 Future close({bool force: false}) =>
116 Future.wait(_servers.map((server) => server.close(force: force))); 121 Future.wait(_servers.map((server) => server.close(force: force)));
117 122
118 /// Returns an HttpConnectionsInfo object summarizing the total number of 123 /// Returns an HttpConnectionsInfo object summarizing the total number of
119 /// current connections handled by all the servers. 124 /// current connections handled by all the servers.
120 HttpConnectionsInfo connectionsInfo() { 125 HttpConnectionsInfo connectionsInfo() {
121 var info = new HttpConnectionsInfo(); 126 var info = new HttpConnectionsInfo();
122 for (var server in _servers) { 127 for (var server in _servers) {
123 var subInfo = server.connectionsInfo(); 128 var subInfo = server.connectionsInfo();
124 info.total += subInfo.total; 129 info.total += subInfo.total;
125 info.active += subInfo.active; 130 info.active += subInfo.active;
126 info.idle += subInfo.idle; 131 info.idle += subInfo.idle;
127 info.closing += subInfo.closing; 132 info.closing += subInfo.closing;
128 } 133 }
129 return info; 134 return info;
130 } 135 }
131 } 136 }
OLDNEW
« no previous file with comments | « pkg/http_multi_server/CHANGELOG.md ('k') | pkg/http_multi_server/lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698