| Index: runtime/bin/socket_stream_impl.dart
|
| diff --git a/runtime/bin/socket_stream_impl.dart b/runtime/bin/socket_stream_impl.dart
|
| index ac750b9c091bf8be33c60f7458d78103de011f97..45c7e4d0e763aab00932557f986642d494efa6a6 100644
|
| --- a/runtime/bin/socket_stream_impl.dart
|
| +++ b/runtime/bin/socket_stream_impl.dart
|
| @@ -109,6 +109,7 @@ class _SocketOutputStream
|
| }
|
|
|
| void close() {
|
| + if (_closing && _closed) return;
|
| if (!_pendingWrites.isEmpty()) {
|
| // Mark the socket for close when all data is written.
|
| _closing = true;
|
| @@ -117,6 +118,10 @@ class _SocketOutputStream
|
| // Close the socket for writing.
|
| _socket._closeWrite();
|
| _closed = true;
|
| + // Invoke the callback asynchronously.
|
| + new Timer(0, (t) {
|
| + if (_onClosed != null) _onClosed();
|
| + });
|
| }
|
| }
|
|
|
| @@ -134,6 +139,10 @@ class _SocketOutputStream
|
| }
|
| }
|
|
|
| + void set onClosed(void callback()) {
|
| + _onClosed = callback;
|
| + }
|
| +
|
| bool _write(List<int> buffer, int offset, int len, bool copyBuffer) {
|
| if (_closing || _closed) throw new StreamException("Stream closed");
|
| int bytesWritten = 0;
|
| @@ -176,6 +185,9 @@ class _SocketOutputStream
|
| if (_closing) {
|
| _socket._closeWrite();
|
| _closed = true;
|
| + if (_onClosed != null) {
|
| + _onClosed();
|
| + }
|
| } else {
|
| if (_onNoPendingWrites != null) _onNoPendingWrites();
|
| }
|
| @@ -199,6 +211,7 @@ class _SocketOutputStream
|
| Socket _socket;
|
| _BufferList _pendingWrites;
|
| Function _onNoPendingWrites;
|
| + Function _onClosed;
|
| bool _closing = false;
|
| bool _closed = false;
|
| }
|
|
|