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

Unified Diff: runtime/bin/file_android.cc

Issue 99583008: Add fallback-implementation for sendfile on linux and android. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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/bin/file_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_android.cc
diff --git a/runtime/bin/file_android.cc b/runtime/bin/file_android.cc
index 54d86f497b8a53d9f9febd2d57677368a40946a5..bfeb8ca2c541725a5a23fdf62a6161cfc7125ba0 100644
--- a/runtime/bin/file_android.cc
+++ b/runtime/bin/file_android.cc
@@ -238,13 +238,25 @@ bool File::Copy(const char* old_path, const char* new_path) {
return false;
}
off64_t offset = 0;
- int bytes = 1;
- while (bytes > 0) {
+ int result = 1;
+ while (result > 0) {
// Loop to ensure we copy everything, and not only up to 2GB.
- bytes = TEMP_FAILURE_RETRY(
+ result = TEMP_FAILURE_RETRY(
sendfile(new_fd, old_fd, &offset, kMaxUint32));
}
- if (bytes < 0) {
+ if (result < 0 && (errno == EINVAL || errno == ENOSYS)) {
+ const intptr_t kBufferSize = 8 * 1024;
+ uint8_t buffer[kBufferSize];
+ while ((result = TEMP_FAILURE_RETRY(
+ read(old_fd, buffer, kBufferSize))) > 0) {
+ int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result));
+ if (wrote != result) {
Bill Hesse 2013/12/13 14:17:59 LGTM, with result = wrote changed to result = -1.
+ result = wrote;
+ break;
+ }
+ }
+ }
+ if (result < 0) {
int e = errno;
VOID_TEMP_FAILURE_RETRY(close(old_fd));
VOID_TEMP_FAILURE_RETRY(close(new_fd));
« no previous file with comments | « no previous file | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698