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

Unified Diff: runtime/bin/socket.cc

Issue 169383003: Make event-handlers edge-triggered and move socket-state to Dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | « runtime/bin/file_system_watcher_linux.cc ('k') | runtime/bin/socket_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket.cc
diff --git a/runtime/bin/socket.cc b/runtime/bin/socket.cc
index 351bfc66334c3f73d9b93394f2afae6ab4246f74..f25bd3465d93c832fd7850c05d8b5f95e79e6ff4 100644
--- a/runtime/bin/socket.cc
+++ b/runtime/bin/socket.cc
@@ -224,7 +224,9 @@ void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
intptr_t length =
DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3));
+ bool short_write = false;
if (short_socket_writes) {
+ if (length > 1) short_write = true;
length = (length + 1) / 2;
}
Dart_TypedData_Type type;
@@ -238,7 +240,13 @@ void FUNCTION_NAME(Socket_WriteList)(Dart_NativeArguments args) {
intptr_t bytes_written = Socket::Write(socket, buffer, length);
if (bytes_written >= 0) {
Dart_TypedDataReleaseData(buffer_obj);
- Dart_SetReturnValue(args, Dart_NewInteger(bytes_written));
+ if (short_write) {
+ // If the write was forced 'short', indicate by returning the negative
+ // number of bytes. A forced short write may not trigger a write event.
+ Dart_SetReturnValue(args, Dart_NewInteger(-bytes_written));
+ } else {
+ Dart_SetReturnValue(args, Dart_NewInteger(bytes_written));
+ }
} else {
// Extract OSError before we release data, as it may override the error.
OSError os_error;
« no previous file with comments | « runtime/bin/file_system_watcher_linux.cc ('k') | runtime/bin/socket_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698