Fix tree.cc error

Due to incorrectly erasing maps in elements while
iterating over it.

https://github.com/moneroexamples/openmonero/issues/150
pull/155/head
moneroexamples 5 years ago
parent 2d9f0cb53b
commit c4579382d7

@ -1135,12 +1135,14 @@ CurrentBlockchainStatus::clean_search_thread_map()
{ {
std::lock_guard<std::mutex> lck (searching_threads_map_mtx); std::lock_guard<std::mutex> lck (searching_threads_map_mtx);
for (auto& st: searching_threads) for (auto it = searching_threads.begin();
it != searching_threads.end();)
{ {
auto& st = *it;
if (search_thread_exist(st.first) if (search_thread_exist(st.first)
&& st.second.get_functor().still_searching() == false) && st.second.get_functor().still_searching() == false)
{ {
// before erasing a search thread, check if there was any // before erasing a search thread, check if there was any
// exception thrown by it // exception thrown by it
try try
@ -1156,7 +1158,11 @@ CurrentBlockchainStatus::clean_search_thread_map()
} }
OMINFO << "Ereasing a search thread"; OMINFO << "Ereasing a search thread";
searching_threads.erase(st.first); it = searching_threads.erase(it);
}
else
{
++it;
} }
} }
} }

Loading…
Cancel
Save