| Index: third_party/mojo/src/mojo/public/dart/src/stub.dart
|
| diff --git a/third_party/mojo/src/mojo/public/dart/src/stub.dart b/third_party/mojo/src/mojo/public/dart/src/stub.dart
|
| index b4ab2930a48d161492814382a8aa6d99ebaf5d48..823873627ec267adaa25db536f4e036bca2990dd 100644
|
| --- a/third_party/mojo/src/mojo/public/dart/src/stub.dart
|
| +++ b/third_party/mojo/src/mojo/public/dart/src/stub.dart
|
| @@ -20,6 +20,9 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| // Query how many bytes are available.
|
| var result = endpoint.query();
|
| assert(result.status.isOk || result.status.isResourceExhausted);
|
| + if (result.bytesRead == 0) {
|
| + throw new MojoCodecError('Unexpected empty message.');
|
| + }
|
|
|
| // Read the data and view as a message.
|
| var bytes = new ByteData(result.bytesRead);
|
| @@ -41,7 +44,7 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| response.buffer.lengthInBytes,
|
| response.handles);
|
| if (!endpoint.status.isOk) {
|
| - throw "message pipe write failed: ${endpoint.status}";
|
| + throw 'message pipe write failed: ${endpoint.status}';
|
| }
|
| if (_isClosing && (_outstandingResponseFutures == 0)) {
|
| // This was the final response future for which we needed to send
|
| @@ -63,9 +66,12 @@ abstract class Stub extends core.MojoEventStreamListener {
|
| throw 'Unexpected write signal in client.';
|
| }
|
|
|
| - void close() {
|
| + // NB: |nodefer| should only be true when calling close() while handling an
|
| + // exception thrown from handleRead(), e.g. when we receive a malformed
|
| + // message.
|
| + void close({bool nodefer : false}) {
|
| if (!isOpen) return;
|
| - if (isInHandler || (_outstandingResponseFutures > 0)) {
|
| + if (!nodefer && (isInHandler || (_outstandingResponseFutures > 0))) {
|
| // Either close() is being called from within handleRead() or
|
| // handleWrite(), or close() is being called while there are outstanding
|
| // response futures. Defer the actual close until all response futures
|
|
|