summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xutil/env_boost.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/env_boost.cc b/util/env_boost.cc
index 1c419e3..ff32dfc 100755
--- a/util/env_boost.cc
+++ b/util/env_boost.cc
@@ -402,8 +402,10 @@ class PosixEnv : public Env {
boost::interprocess::file_lock fl(fname.c_str());
BoostFileLock * my_lock = new BoostFileLock();
my_lock->fl_ = std::move(fl);
- my_lock->fl_.lock();
- *lock = my_lock;
+ if (my_lock->fl_.try_lock())
+ *lock = my_lock;
+ else
+ result = Status::IOError("acquiring lock " + fname + " failed");
} catch (const std::exception & e) {
result = Status::IOError("lock " + fname, e.what());
}