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

Unified Diff: sdk/lib/io/websocket_impl.dart

Issue 1234163002: Fix a WebSocket crash. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Code review changes Created 5 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
« no previous file with comments | « CHANGELOG.md ('k') | tests/standalone/io/web_socket_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/websocket_impl.dart
diff --git a/sdk/lib/io/websocket_impl.dart b/sdk/lib/io/websocket_impl.dart
index 265760690923f502512435c8e6d8df3d1fada22a..9693873edb56992015caf0b2ea837bd04f53e1cf 100644
--- a/sdk/lib/io/websocket_impl.dart
+++ b/sdk/lib/io/websocket_impl.dart
@@ -903,6 +903,10 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
_subscription.pause();
_controller = new StreamController(sync: true,
onListen: _subscription.resume,
+ onCancel: () {
+ _subscription.cancel();
+ _subscription = null;
+ },
onPause: _subscription.pause,
onResume: _subscription.resume);
@@ -965,7 +969,7 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
// processed if received.
// 2) set a timer terminate the connection if a close frame is
// not received.
- if (!_controller.hasListener) {
+ if (!_controller.hasListener && _subscription != null) {
_controller.stream.drain().catchError((_) => {});
}
if (_closeTimer == null) {
@@ -974,7 +978,7 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket {
// Reuse code and reason from the local close.
_closeCode = _outCloseCode;
_closeReason = _outCloseReason;
- _subscription.cancel();
+ if (_subscription != null) _subscription.cancel();
_controller.close();
_webSockets.remove(_serviceId);
});
« no previous file with comments | « CHANGELOG.md ('k') | tests/standalone/io/web_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698