Chromium Code Reviews| Index: sdk/lib/io/http_impl.dart |
| diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart |
| index c749cebd26919281acf0b576c50d0dbdfd58f954..c4aaf70b9668ee491703f7a1bef5f2f5ec95cb22 100644 |
| --- a/sdk/lib/io/http_impl.dart |
| +++ b/sdk/lib/io/http_impl.dart |
| @@ -546,28 +546,28 @@ class _HttpOutboundConsumer implements StreamConsumer { |
| _HttpOutboundConsumer(_HttpOutboundMessage this._outbound); |
| void _onPause() { |
| - if (_controller.isPaused) { |
| - _subscription.pause(); |
| - } else { |
| - _subscription.resume(); |
| - } |
| + _subscription.pause(); |
| + } |
| + void _onResume() { |
| + _subscription.resume(); |
| } |
| - void _onListen() { |
| - if (!_controller.hasListener && _subscription != null) { |
| - _subscription.cancel(); |
| + void _onCancel() { |
| + if (_subscription != null) { |
| + StreamSubscription subscription = _subscription; |
| + _subscription = null; |
| + subscription.cancel(); |
| } |
| } |
| _ensureController() { |
| if (_controller != null) return; |
| _controller = new StreamController(onPause: _onPause, |
| - onResume: _onPause, |
| - onListen: _onListen, |
| - onCancel: _onListen); |
| + onResume: _onResume, |
| + onCancel: _onCancel); |
| _outbound._addStream(_controller.stream) |
| .then((_) { |
| - _onListen(); // Make sure we unsubscribe. |
| + _onCancel(); // Make sure we unsubscribe. |
| _done(); |
| _closeCompleter.complete(_outbound); |
| }, |
| @@ -592,6 +592,7 @@ class _HttpOutboundConsumer implements StreamConsumer { |
| Future addStream(var stream) { |
| _ensureController(); |
| _completer = new Completer(); |
| + Future result = _completer.future; |
|
Anders Johnsen
2013/05/22 13:07:08
Nooo... :)
floitsch
2013/05/22 16:26:29
Apparently this was necessary.
Add comment. (it's
Lasse Reichstein Nielsen
2013/05/24 06:02:49
It should not be necessary any more after I preven
|
| _subscription = stream.listen( |
| (data) { |
| _controller.add(data); |
| @@ -603,7 +604,7 @@ class _HttpOutboundConsumer implements StreamConsumer { |
| _done(error); |
| }, |
| cancelOnError: true); |
| - return _completer.future; |
| + return result; |
| } |
| Future close() { |