diff --git a/src/util.cpp b/src/util.cpp index a391c5e857bf09..b41e61ddf5fa97 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -174,6 +174,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.h b/src/util.h index 23b2a787e4e4c8..957654124963d5 100644 --- a/src/util.h +++ b/src/util.h @@ -77,6 +77,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 774739f95f4176..bab6fd2f164249 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -126,6 +126,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()