Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2017-08-22 20:53:00 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2017-09-13 16:25:30 +0300
commit3fe31a5a6cbd469a91c67a02b9517b3e5fd81011 (patch)
treed40a9ddf1f7623868238ff44e8eacbde83fa9c07 /indexer/altitude_loader.cpp
parent52cd23bfb5ef80426f7b04c13b2fc841a0bd9e91 (diff)
[routing] Fixed a data race in AltitudeLoader.
AltitudeLoader holds a FileReader of the altitudes section. This reader, being a caching one, is not thread safe. However, AltitudeLoader did not keep the MwmHandle from which it was supposed to construct its reader, so the reader could be reused (via MwmValue via MwmHandle) by another thread. FeaturesRoadGraph tries to avoid this issue by keeping its own cache of MwmHandles but it did not stop RoadGeometry from bypassing this cache when creating its AltitudeLoader. The question of whether we need to fix this other cache and whether we need it at all is out of the scope of this CL.
Diffstat (limited to 'indexer/altitude_loader.cpp')
-rw-r--r--indexer/altitude_loader.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/indexer/altitude_loader.cpp b/indexer/altitude_loader.cpp
index cb05bc4cf6..57e8189064 100644
--- a/indexer/altitude_loader.cpp
+++ b/indexer/altitude_loader.cpp
@@ -29,8 +29,14 @@ void LoadAndMap(size_t dataSize, ReaderSource<FilesContainerR::TReader> & src, T
namespace feature
{
-AltitudeLoader::AltitudeLoader(MwmValue const & mwmValue)
+AltitudeLoader::AltitudeLoader(Index const & index, MwmSet::MwmId const & mwmId)
+ : m_handle(index.GetMwmHandleById(mwmId))
{
+ if (!m_handle.IsAlive())
+ return;
+
+ auto const & mwmValue = *m_handle.GetValue<MwmValue>();
+
m_countryFileName = mwmValue.GetCountryFileName();
if (mwmValue.GetHeader().GetFormat() < version::Format::v8)