Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Unified Diff: runtime/bin/socket_patch.dart

Issue 12089071: IO v2: Handle illegal arguments to socket writes (Closed) Base URL: http://dart.googlecode.com/svn/experimental/lib_v2_io/dart/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_patch.dart
===================================================================
--- runtime/bin/socket_patch.dart (revision 17848)
+++ 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);
Mads Ager (google) 2013/01/31 07:53:30 Accidental indentation change?
Søren Gjesse 2013/01/31 12:12:01 Done.
+ 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);
}
}
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698