aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/util/system.cpp6
-rw-r--r--src/util/system.h1
-rw-r--r--src/wallet/db.cpp2
3 files changed, 9 insertions, 0 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 06317a3a90..d8b70ee52c 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -116,6 +116,12 @@ bool LockDirectory(const fs::path& directory, const std::string lockfile_name, b
return true;
}
+void UnlockDirectory(const fs::path& directory, const std::string& lockfile_name)
+{
+ std::lock_guard<std::mutex> lock(cs_dir_locks);
+ dir_locks.erase((directory / lockfile_name).string());
+}
+
void ReleaseDirectoryLocks()
{
std::lock_guard<std::mutex> ulock(cs_dir_locks);
diff --git a/src/util/system.h b/src/util/system.h
index 5932e55793..17723d427d 100644
--- a/src/util/system.h
+++ b/src/util/system.h
@@ -70,6 +70,7 @@ int RaiseFileDescriptorLimit(int nMinFD);
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length);
bool RenameOver(fs::path src, fs::path dest);
bool LockDirectory(const fs::path& directory, const std::string lockfile_name, bool probe_only=false);
+void UnlockDirectory(const fs::path& directory, const std::string& lockfile_name);
bool DirIsWritable(const fs::path& directory);
/** Release all directory locks. This is used for unit testing only, at runtime
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index 24911846ed..463f8e1f41 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -136,6 +136,8 @@ void BerkeleyEnvironment::Close()
DbEnv((u_int32_t)0).remove(strPath.c_str(), 0);
if (error_file) fclose(error_file);
+
+ UnlockDirectory(strPath, ".walletlock");
}
void BerkeleyEnvironment::Reset()