| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/dartutils.h" | 5 #include "bin/dartutils.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 262 } |
| 263 | 263 |
| 264 | 264 |
| 265 static uint8_t* SocketReadUntilEOF(intptr_t socket, intptr_t* response_len) { | 265 static uint8_t* SocketReadUntilEOF(intptr_t socket, intptr_t* response_len) { |
| 266 const intptr_t kInitialBufferSize = 16 * KB; | 266 const intptr_t kInitialBufferSize = 16 * KB; |
| 267 intptr_t buffer_size = kInitialBufferSize; | 267 intptr_t buffer_size = kInitialBufferSize; |
| 268 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(buffer_size)); | 268 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(buffer_size)); |
| 269 ASSERT(buffer != NULL); | 269 ASSERT(buffer != NULL); |
| 270 intptr_t buffer_cursor = 0; | 270 intptr_t buffer_cursor = 0; |
| 271 do { | 271 do { |
| 272 ssize_t bytes_read = Socket::Read(socket, &buffer[buffer_cursor], | 272 int bytes_read = Socket::Read(socket, &buffer[buffer_cursor], |
| 273 buffer_size - buffer_cursor - 1); | 273 buffer_size - buffer_cursor - 1); |
| 274 if (bytes_read < 0) { | 274 if (bytes_read < 0) { |
| 275 free(buffer); | 275 free(buffer); |
| 276 return NULL; | 276 return NULL; |
| 277 } | 277 } |
| 278 | 278 |
| 279 buffer_cursor += bytes_read; | 279 buffer_cursor += bytes_read; |
| 280 | 280 |
| 281 if (bytes_read == 0) { | 281 if (bytes_read == 0) { |
| 282 *response_len = buffer_cursor; | 282 *response_len = buffer_cursor; |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 new CObjectString(CObject::NewString(os_error->message())); | 1103 new CObjectString(CObject::NewString(os_error->message())); |
| 1104 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1104 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 1105 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1105 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 1106 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1106 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 1107 result->SetAt(2, error_message); | 1107 result->SetAt(2, error_message); |
| 1108 return result; | 1108 return result; |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 } // namespace bin | 1111 } // namespace bin |
| 1112 } // namespace dart | 1112 } // namespace dart |
| OLD | NEW |