Pass duped FDs to the vdex_for_odex_ OatFileInfo.
The original FDs will be owned by the odex_ OatFileInfo.
Test: test.py
Bug: 181534599
Change-Id: I7b0f006de6fda3574645a1c2f2c27f09ee28c298
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index d3c5da2..0fee0ef 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -109,6 +109,9 @@
<< " oat_fd=" << oat_fd;
CHECK_LE(vdex_fd, 0) << "zip_fd must be provided with valid vdex_fd. zip_fd=" << zip_fd
<< " vdex_fd=" << vdex_fd;;
+ CHECK(!UseFdToReadFiles());
+ } else {
+ CHECK(UseFdToReadFiles());
}
dex_location_.assign(dex_location);
@@ -125,7 +128,12 @@
if (DexLocationToOdexFilename(dex_location_, isa_, &odex_file_name, &error_msg)) {
odex_.Reset(odex_file_name, UseFdToReadFiles(), zip_fd, vdex_fd, oat_fd);
std::string vdex_file_name = GetVdexFilename(odex_file_name);
- vdex_for_odex_.Reset(vdex_file_name, UseFdToReadFiles(), zip_fd, vdex_fd, oat_fd);
+ // We dup FDs as the odex_ will claim ownership.
+ vdex_for_odex_.Reset(vdex_file_name,
+ UseFdToReadFiles(),
+ DupCloexec(zip_fd),
+ DupCloexec(vdex_fd),
+ DupCloexec(oat_fd));
} else {
LOG(WARNING) << "Failed to determine odex file name: " << error_msg;
}