summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/oat_file_assistant.cc15
-rw-r--r--runtime/oat_file_assistant.h1
2 files changed, 4 insertions, 12 deletions
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 2f67263285..208d2b98fa 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -96,9 +96,8 @@ OatFileAssistant::OatFileAssistant(const char* dex_location,
OatFileAssistant::~OatFileAssistant() {
// Clean up the lock file.
- if (lock_file_.get() != nullptr) {
- lock_file_->Erase();
- TEMP_FAILURE_RETRY(unlink(lock_file_->GetPath().c_str()));
+ if (flock_.HasFile()) {
+ TEMP_FAILURE_RETRY(unlink(flock_.GetFile()->GetPath().c_str()));
}
}
@@ -121,7 +120,7 @@ bool OatFileAssistant::IsInBootClassPath() {
bool OatFileAssistant::Lock(std::string* error_msg) {
CHECK(error_msg != nullptr);
- CHECK(lock_file_.get() == nullptr) << "OatFileAssistant::Lock already acquired";
+ CHECK(!flock_.HasFile()) << "OatFileAssistant::Lock already acquired";
if (OatFileName() == nullptr) {
*error_msg = "Failed to determine lock file";
@@ -129,13 +128,7 @@ bool OatFileAssistant::Lock(std::string* error_msg) {
}
std::string lock_file_name = *OatFileName() + ".flock";
- lock_file_.reset(OS::CreateEmptyFile(lock_file_name.c_str()));
- if (lock_file_.get() == nullptr) {
- *error_msg = "Failed to create lock file " + lock_file_name;
- return false;
- }
-
- if (!flock_.Init(lock_file_.get(), error_msg)) {
+ if (!flock_.Init(lock_file_name.c_str(), error_msg)) {
TEMP_FAILURE_RETRY(unlink(lock_file_name.c_str()));
return false;
}
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index a25ee31d0d..bb8dd27541 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -353,7 +353,6 @@ class OatFileAssistant {
// To implement Lock(), we lock a dummy file where the oat file would go
// (adding ".flock" to the target file name) and retain the lock for the
// remaining lifetime of the OatFileAssistant object.
- std::unique_ptr<File> lock_file_;
ScopedFlock flock_;
// In a properly constructed OatFileAssistant object, dex_location_ should