From 2f8b8f479bb43729ca2ff40929e8463347b0b7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Thu, 31 Jan 2019 00:05:18 +0000 Subject: wallet: Close wallet env lock file Close .walletlock file when a BerkeleyEnvironment is deleted. --- src/util/system.cpp | 6 ++++++ src/util/system.h | 1 + 2 files changed, 7 insertions(+) (limited to 'src/util') 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 lock(cs_dir_locks); + dir_locks.erase((directory / lockfile_name).string()); +} + void ReleaseDirectoryLocks() { std::lock_guard 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 -- cgit v1.2.3