| Index: runtime/bin/socket_patch.dart
|
| diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
|
| index 67fbadf2baccc4f624e793e3e07a65aa50f84d00..f5c302656fb05e324a09839d69dc364ef4875e31 100644
|
| --- a/runtime/bin/socket_patch.dart
|
| +++ b/runtime/bin/socket_patch.dart
|
| @@ -771,6 +771,7 @@ class _Socket extends Stream<List<int>> implements Socket {
|
| _SocketStreamConsumer _consumer;
|
| IOSink _sink;
|
| var _subscription;
|
| + var _detachReady;
|
|
|
| _Socket(RawSocket this._raw) {
|
| _controller = new StreamController<List<int>>(
|
| @@ -851,6 +852,17 @@ class _Socket extends Stream<List<int>> implements Socket {
|
| String get remoteHost => _raw.remoteHost;
|
| int get remotePort => _raw.remotePort;
|
|
|
| + Future _detachRaw() {
|
| + _detachReady = new Completer();
|
| + _sink.close();
|
| + return _detachReady.future.then((_) {
|
| + assert(_consumer.buffer == null);
|
| + var raw = _raw;
|
| + _raw = null;
|
| + return [raw, _subscription];
|
| + });
|
| + }
|
| +
|
| // Ensure a subscription on the raw socket. Both the stream and the
|
| // consumer needs a subscription as they share the error and done
|
| // events from the raw socket.
|
| @@ -938,9 +950,13 @@ class _Socket extends Stream<List<int>> implements Socket {
|
| }
|
|
|
| void _consumerDone() {
|
| - if (_raw != null) {
|
| - _raw.shutdown(SocketDirection.SEND);
|
| - _disableWriteEvent();
|
| + if (_detachReady != null) {
|
| + _detachReady.complete(null);
|
| + } else {
|
| + if (_raw != null) {
|
| + _raw.shutdown(SocketDirection.SEND);
|
| + _disableWriteEvent();
|
| + }
|
| }
|
| }
|
| }
|
|
|