| Index: runtime/bin/socket_patch.dart
|
| ===================================================================
|
| --- runtime/bin/socket_patch.dart (revision 17895)
|
| +++ runtime/bin/socket_patch.dart (working copy)
|
| @@ -690,27 +690,31 @@
|
| }
|
|
|
| void write() {
|
| - if (subscription == null) return;
|
| - assert(buffer != null);
|
| - // Write as much as possible.
|
| - offset += socket._write(buffer, offset, buffer.length - offset);
|
| - if (offset < buffer.length) {
|
| - if (!paused) {
|
| - paused = true;
|
| - // TODO(ajohnsen): It would be nice to avoid this check.
|
| - // Some info: socket._write can emit an event, if it fails to write.
|
| - // If the user closes the socket in that event, stop() will be called
|
| - // before we get a change to pause.
|
| - if (subscription == null) return;
|
| - subscription.pause();
|
| + try {
|
| + if (subscription == null) return;
|
| + assert(buffer != null);
|
| + // Write as much as possible.
|
| + offset += socket._write(buffer, offset, buffer.length - offset);
|
| + if (offset < buffer.length) {
|
| + if (!paused) {
|
| + paused = true;
|
| + // TODO(ajohnsen): It would be nice to avoid this check.
|
| + // Some info: socket._write can emit an event, if it fails to write.
|
| + // If the user closes the socket in that event, stop() will be called
|
| + // before we get a change to pause.
|
| + if (subscription == null) return;
|
| + subscription.pause();
|
| + }
|
| + socket._enableWriteEvent();
|
| + } else {
|
| + buffer = null;
|
| + if (paused) {
|
| + paused = false;
|
| + subscription.resume();
|
| + }
|
| }
|
| - socket._enableWriteEvent();
|
| - } else {
|
| - buffer = null;
|
| - if (paused) {
|
| - paused = false;
|
| - subscription.resume();
|
| - }
|
| + } catch (e) {
|
| + socket._consumerDone(e);
|
| }
|
| }
|
|
|
| @@ -906,12 +910,12 @@
|
| }
|
| }
|
|
|
| - void _consumerDone() {
|
| + void _consumerDone([error]) {
|
| if (_raw != null) {
|
| _raw.shutdown(SocketDirection.SEND);
|
| _disableWriteEvent();
|
| }
|
| - _done();
|
| + _done(error);
|
| }
|
| }
|
|
|
|
|