From 01e65629ff66663106cb1f24471a1cf5ab9d6e6e Mon Sep 17 00:00:00 2001 From: Kajari Ghosh Date: Mon, 2 Apr 2018 15:28:29 -0400 Subject: [PATCH] put a lock infront of the clear function to make it threadsafe --- include/engine/search_engine_data.hpp | 5 ++++- src/engine/search_engine_data.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/engine/search_engine_data.hpp b/include/engine/search_engine_data.hpp index b1aaec07329..a193254470b 100644 --- a/include/engine/search_engine_data.hpp +++ b/include/engine/search_engine_data.hpp @@ -6,7 +6,8 @@ #include "util/query_heap.hpp" #include "util/typedefs.hpp" -#include +// #include +#include namespace osrm { @@ -57,6 +58,8 @@ template <> struct SearchEngineData static ManyToManyHeapPtr many_to_many_heap; static UnpackingCache unpacking_cache; + boost::shared_mutex _shared_access_across_threads; + void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes); void InitializeOrClearSecondThreadLocalStorage(unsigned number_of_nodes); diff --git a/src/engine/search_engine_data.cpp b/src/engine/search_engine_data.cpp index 88897a38462..bc7ad766b58 100644 --- a/src/engine/search_engine_data.cpp +++ b/src/engine/search_engine_data.cpp @@ -93,6 +93,7 @@ void SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage(unsigne void SearchEngineData::InitializeOrClearUnpackingCacheGlobalStorage(unsigned timestamp) { + boost::unique_lock lock(_shared_access_across_threads); unpacking_cache.Clear(timestamp); }