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

Unified Diff: pkg/http_multi_server/lib/src/utils.dart

Issue 375113002: Swallow errors in subscriptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/http_multi_server/lib/src/utils.dart
diff --git a/pkg/http_multi_server/lib/src/utils.dart b/pkg/http_multi_server/lib/src/utils.dart
index 9e95aba5f9d82612e7bf2d3632c762dd156e8ced..57cf8a6ecdccb270416aa66016537ddc3d8c7dfe 100644
--- a/pkg/http_multi_server/lib/src/utils.dart
+++ b/pkg/http_multi_server/lib/src/utils.dart
@@ -18,9 +18,14 @@ Stream mergeStreams(Iterable<Stream> streams) {
controller = new StreamController(onListen: () {
for (var stream in streams) {
var subscription;
- subscription = stream.listen(controller.add,
- onError: controller.addError,
- onDone: () {
+ subscription = stream.listen(controller.add, onError: (error, trace) {
+ // If one of the subscriptions has an error (usually IPv6 failing late),
nweiz 2014/07/09 02:02:01 This comment should mention the tracking issue. It
+ // then just remove it and ignore the error.
+ subscriptions.remove(subscription);
nweiz 2014/07/09 02:02:01 If this isn't the last subscription, cancel it as
+
+ // If the last subscription errored, though, pass it on.
+ if (subscriptions.isEmpty) controller.addError(error, trace);
+ }, onDone: () {
subscriptions.remove(subscription);
if (subscriptions.isEmpty) controller.close();
});
@@ -42,21 +47,3 @@ Stream mergeStreams(Iterable<Stream> streams) {
return controller.stream;
}
-
-/// A cache for [supportsIpV6].
-bool _supportsIpV6;
-
-/// Returns whether this computer supports binding to IPv6 addresses.
-Future<bool> get supportsIpV6 {
- if (_supportsIpV6 != null) return new Future.value(_supportsIpV6);
-
- return ServerSocket.bind(InternetAddress.LOOPBACK_IP_V6, 0).then((socket) {
- _supportsIpV6 = true;
- socket.close();
- return true;
- }).catchError((error) {
- if (error is! SocketException) throw error;
- _supportsIpV6 = false;
- return false;
- });
-}

Powered by Google App Engine
This is Rietveld 408576698