| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/io_buffer.h" | 5 #include "bin/io_buffer.h" |
| 6 #include "bin/isolate_data.h" | 6 #include "bin/isolate_data.h" |
| 7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
| 8 #include "bin/socket.h" | 8 #include "bin/socket.h" |
| 9 #include "bin/thread.h" | 9 #include "bin/thread.h" |
| 10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 void FUNCTION_NAME(Socket_Available)(Dart_NativeArguments args) { | 79 void FUNCTION_NAME(Socket_Available)(Dart_NativeArguments args) { |
| 80 intptr_t socket = | 80 intptr_t socket = |
| 81 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0)); | 81 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0)); |
| 82 intptr_t available = Socket::Available(socket); | 82 intptr_t available = Socket::Available(socket); |
| 83 if (available >= 0) { | 83 if (available >= 0) { |
| 84 Dart_SetReturnValue(args, Dart_NewInteger(available)); | 84 Dart_SetReturnValue(args, Dart_NewInteger(available)); |
| 85 } else { | 85 } else { |
| 86 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 86 // Available failed. Mark socket as having data, to trigger a future read |
| 87 // event where the actual error can be reported. |
| 88 Dart_SetReturnValue(args, Dart_NewInteger(1)); |
| 87 } | 89 } |
| 88 } | 90 } |
| 89 | 91 |
| 90 | 92 |
| 91 void FUNCTION_NAME(Socket_Read)(Dart_NativeArguments args) { | 93 void FUNCTION_NAME(Socket_Read)(Dart_NativeArguments args) { |
| 92 static bool short_socket_reads = Dart_IsVMFlagSet("short_socket_read"); | 94 static bool short_socket_reads = Dart_IsVMFlagSet("short_socket_read"); |
| 93 intptr_t socket = | 95 intptr_t socket = |
| 94 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0)); | 96 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0)); |
| 95 int64_t length = 0; | 97 int64_t length = 0; |
| 96 if (DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &length)) { | 98 if (DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &length)) { |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { | 688 intptr_t Socket::GetSocketIdNativeField(Dart_Handle socket_obj) { |
| 687 intptr_t socket = 0; | 689 intptr_t socket = 0; |
| 688 Dart_Handle err = | 690 Dart_Handle err = |
| 689 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); | 691 Dart_GetNativeInstanceField(socket_obj, kSocketIdNativeField, &socket); |
| 690 if (Dart_IsError(err)) Dart_PropagateError(err); | 692 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 691 return socket; | 693 return socket; |
| 692 } | 694 } |
| 693 | 695 |
| 694 } // namespace bin | 696 } // namespace bin |
| 695 } // namespace dart | 697 } // namespace dart |
| OLD | NEW |