Merge "Bugfix:updater always retry apply patch failed,when memcpy failed." am: e81719dde3
am: b0337774b2

Change-Id: I8a874f491f6a6ee452a3a18ae53920903ec11a44
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp
index 95389da..8682e12 100644
--- a/applypatch/applypatch.cpp
+++ b/applypatch/applypatch.cpp
@@ -332,6 +332,17 @@
       success = true;
       break;
     }
+
+    if (ota_close(fd) != 0) {
+      printf("failed to close %s: %s\n", partition, strerror(errno));
+      return -1;
+    }
+
+    fd.reset(ota_open(partition, O_RDWR));
+    if (fd == -1) {
+      printf("failed to reopen %s for retry write && verify: %s\n", partition, strerror(errno));
+      return -1;
+    }
   }
 
   if (!success) {