summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/base/scoped_flock.cc8
-rw-r--r--runtime/base/scoped_flock.h9
2 files changed, 15 insertions, 2 deletions
diff --git a/runtime/base/scoped_flock.cc b/runtime/base/scoped_flock.cc
index 5394e53fa3..842f922198 100644
--- a/runtime/base/scoped_flock.cc
+++ b/runtime/base/scoped_flock.cc
@@ -117,8 +117,12 @@ ScopedFlock::~ScopedFlock() {
if (file_.get() != nullptr) {
int flock_result = TEMP_FAILURE_RETRY(flock(file_->Fd(), LOCK_UN));
if (flock_result != 0) {
- PLOG(FATAL) << "Unable to unlock file " << file_->GetPath();
- UNREACHABLE();
+ // Only printing a warning is okay since this is only used with either:
+ // 1) a non-blocking Init call, or
+ // 2) as a part of a seperate binary (eg dex2oat) which has it's own timeout logic to prevent
+ // deadlocks.
+ // This means we can be sure that the warning won't cause a deadlock.
+ PLOG(WARNING) << "Unable to unlock file " << file_->GetPath();
}
int close_result = -1;
if (file_->ReadOnlyMode()) {
diff --git a/runtime/base/scoped_flock.h b/runtime/base/scoped_flock.h
index cc22056443..49d57f0ee3 100644
--- a/runtime/base/scoped_flock.h
+++ b/runtime/base/scoped_flock.h
@@ -25,6 +25,15 @@
namespace art {
+// A scoped file-lock implemented using flock. The file is locked by calling the Init function and
+// is released during destruction. Note that failing to unlock the file only causes a warning to be
+// printed. Users should take care that this does not cause potential deadlocks.
+//
+// Only printing a warning on unlock failure is okay since this is only used with either:
+// 1) a non-blocking Init call, or
+// 2) as a part of a seperate binary (eg dex2oat) which has it's own timeout logic to prevent
+// deadlocks.
+// This means we can be sure that the warning won't cause a deadlock.
class ScopedFlock {
public:
ScopedFlock();