| Index: mojo/public/dart/src/stub.dart
|
| diff --git a/mojo/public/dart/src/stub.dart b/mojo/public/dart/src/stub.dart
|
| index 9008f55e2abef06c557c58a739ac85b8a8d5c697..c932584b2655f0fbc33bbf33fbd07608a114ec9d 100644
|
| --- a/mojo/public/dart/src/stub.dart
|
| +++ b/mojo/public/dart/src/stub.dart
|
| @@ -52,9 +52,11 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| // This was the final response future for which we needed to send
|
| // a response. It is safe to close.
|
| super.close().then((_) {
|
| - _isClosing = false;
|
| - _closeCompleter.complete(null);
|
| - _closeCompleter = null;
|
| + if (_isClosing) {
|
| + _isClosing = false;
|
| + _closeCompleter.complete(null);
|
| + _closeCompleter = null;
|
| + }
|
| });
|
| }
|
| }
|
| @@ -63,9 +65,11 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| // We are closing, there is no response to send for this message, and
|
| // there are no outstanding response futures. Do the close now.
|
| super.close().then((_) {
|
| - _isClosing = false;
|
| - _closeCompleter.complete(null);
|
| - _closeCompleter = null;
|
| + if (_isClosing) {
|
| + _isClosing = false;
|
| + _closeCompleter.complete(null);
|
| + _closeCompleter = null;
|
| + }
|
| });
|
| }
|
| }
|
| @@ -74,13 +78,13 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| throw 'Unexpected write signal in client.';
|
| }
|
|
|
| - // NB: |nodefer| should only be true when calling close() while handling an
|
| + // NB: |immediate| should only be true when calling close() while handling an
|
| // exception thrown from handleRead(), e.g. when we receive a malformed
|
| // message, or when we have received the PEER_CLOSED event.
|
| @override
|
| - Future close({bool nodefer: false}) {
|
| + Future close({bool immediate: false}) {
|
| if (isOpen &&
|
| - !nodefer &&
|
| + !immediate &&
|
| (isInHandler || (_outstandingResponseFutures > 0))) {
|
| // Either close() is being called from within handleRead() or
|
| // handleWrite(), or close() is being called while there are outstanding
|
| @@ -90,7 +94,7 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| _closeCompleter = new Completer();
|
| return _closeCompleter.future;
|
| } else {
|
| - return super.close(nodefer: nodefer).then((_) {
|
| + return super.close(immediate: immediate).then((_) {
|
| if (_isClosing) {
|
| _isClosing = false;
|
| _closeCompleter.complete(null);
|
|
|