Index: runtime/bin/socket.cc |
diff --git a/runtime/bin/socket.cc b/runtime/bin/socket.cc |
index 351bfc66334c3f73d9b93394f2afae6ab4246f74..d87e0178c75f6af5b97405af0929e7165ee502dd 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,11 @@ 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) { |
Søren Gjesse
2014/02/18 14:28:00
Can we post a write event instead of this "trick"?
Anders Johnsen
2014/02/19 09:43:03
It's extremely custom how we post such an event. I
|
+ 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; |