aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Vinícius Freire de Araújo Ribeiro <thiagovfar@gmail.com>2013-05-19 19:08:06 -0300
committerThiago Vinícius Freire de Araújo Ribeiro <thiagovfar@gmail.com>2013-05-21 22:24:38 -0300
commit5f05ac7c88a7b9c964f922bb4da5d551b545d4c3 (patch)
tree12485bc8b3ddbeb3f1ebdaacec55fe5e7580017f
parentc6834e32a0bfef51cc24d86d4955ffe078d2f746 (diff)
downloadbootable_recovery-5f05ac7c88a7b9c964f922bb4da5d551b545d4c3.zip
bootable_recovery-5f05ac7c88a7b9c964f922bb4da5d551b545d4c3.tar.gz
bootable_recovery-5f05ac7c88a7b9c964f922bb4da5d551b545d4c3.tar.bz2
recovery: Fix adb backup
Using http://goo.gl/6AQ3u might fail. The resulting backup consists of a tarball of the filesystem being backed up, but it might end up truncated, for reasons yet unknown. Issuing adb backup data, for instance, causes recovery to call tar, streaming it's stdout <a> through a socket <b>. The adb client reads from <b> and copies what it to the final backup file. Somehow, sometimes, not all the content generated at <a> is read at the adb client, which causes a truncated tar file to result. I'm unsure why this happens: Doesn't <a> get flushed before <b> is closed? Or is it that <b> is closed with outstanding data in its buffers, which never make it to the other side? Either calling sync() or sleep() seems to remedy the issue, but I'm not sure if sync() has any effect on sockets or pipes. I also understand that sleeping for some time is not the best solution to a race condition. Therefore, I'm adding calls to sync() and sleep() and waiting for reviews from someone who knows better how these calls work. Patch set 2: Remove sync() call Change-Id: If4733066fdad809eb73e87c670f37acc4debe82d
-rw-r--r--nandroid.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/nandroid.c b/nandroid.c
index 1e2adbf..2f872d1 100644
--- a/nandroid.c
+++ b/nandroid.c
@@ -868,7 +868,9 @@ int bu_main(int argc, char** argv) {
}
// fprintf(stderr, "%d %d %s\n", fd, STDOUT_FILENO, argv[3]);
- return nandroid_dump(partition);
+ int ret = nandroid_dump(partition);
+ sleep(10);
+ return ret;
}
else if (strcmp(argv[2], "restore") == 0) {
if (argc != 3) {