wallet: Close wallet env lock file

Close .walletlock file when a BerkeleyEnvironment is deleted.
pull/643/head
João Barbosa 6 years ago
parent 8602a1e6ae
commit 2f8b8f479b

@ -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);

@ -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

@ -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()

Loading…
Cancel
Save