From ac2bf0f240049f17b2ced9c26a0c0e63a66dfd05 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 13 Feb 2018 14:12:30 +0100 Subject: [PATCH] util: Use unique_ptr in locks map Wrap the boost::interprocess::file_lock in a std::unique_ptr inside the map that keeps track of per-directory locks. This fixes a build issue with the clang 4.0.0+boost-1.58.0p8 version combo on OpenBSD 6.2, and should have no effect otherwise. --- src/util.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 6738bbc6e4470..c22913e37e1d1 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -380,13 +380,14 @@ bool LockDirectory(const fs::path& directory, const std::string lockfile_name, b if (file) fclose(file); try { - static std::map locks; - boost::interprocess::file_lock& lock = locks.emplace(pathLockFile.string(), pathLockFile.string().c_str()).first->second; - if (!lock.try_lock()) { + static std::map> locks; + std::unique_ptr &lock = locks.emplace(pathLockFile.string(), + MakeUnique(pathLockFile.string().c_str())).first->second; + if (!lock->try_lock()) { return false; } if (probe_only) { - lock.unlock(); + lock->unlock(); } } catch (const boost::interprocess::interprocess_exception& e) { return error("Error while attempting to lock directory %s: %s", directory.string(), e.what());