From 2319d19fcdc6126d8ca745e00fd23768432b5e83 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Wed, 24 Jan 2024 21:48:45 +0300 Subject: [PATCH] Deadlocked by F777 --- loader/src/loader/Index.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/loader/src/loader/Index.cpp b/loader/src/loader/Index.cpp index 9d53acf1..e6ed1792 100644 --- a/loader/src/loader/Index.cpp +++ b/loader/src/loader/Index.cpp @@ -507,10 +507,12 @@ std::vector Index::getItems() const { } std::vector Index::getLatestItems() const { - std::scoped_lock lock(m_impl->m_itemsMutex); + std::unique_lock lock(m_impl->m_itemsMutex); std::vector res; for (auto& [modID, versions] : m_impl->m_items) { + lock.unlock(); res.push_back(this->getMajorItem(modID)); + lock.lock(); } return res; } @@ -577,7 +579,7 @@ IndexItemHandle Index::getItem( std::string const& id, std::optional version ) const { - std::scoped_lock lock(m_impl->m_itemsMutex); + std::unique_lock lock(m_impl->m_itemsMutex); if (m_impl->m_items.count(id)) { auto versions = m_impl->m_items.at(id); if (version) { @@ -588,6 +590,7 @@ IndexItemHandle Index::getItem( } } } + lock.unlock(); return this->getMajorItem(id); }