diff --git a/src/CurrentBlockchainStatus.cpp b/src/CurrentBlockchainStatus.cpp index 3086d40..000b955 100755 --- a/src/CurrentBlockchainStatus.cpp +++ b/src/CurrentBlockchainStatus.cpp @@ -1135,12 +1135,14 @@ CurrentBlockchainStatus::clean_search_thread_map() { std::lock_guard 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) && st.second.get_functor().still_searching() == false) { - // before erasing a search thread, check if there was any // exception thrown by it try @@ -1156,7 +1158,11 @@ CurrentBlockchainStatus::clean_search_thread_map() } OMINFO << "Ereasing a search thread"; - searching_threads.erase(st.first); + it = searching_threads.erase(it); + } + else + { + ++it; } } }