forked from organicmaps/organicmaps
[DIFFS] Fixed deadlock on start
This commit is contained in:
parent
4554859726
commit
645a781cfb
3 changed files with 15 additions and 1 deletions
|
@ -99,13 +99,18 @@ void Manager::SetStatus(Status status)
|
|||
FileInfo const & Manager::InfoFor(storage::TCountryId const & countryId) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
ASSERT(HasDiffFor(countryId), ());
|
||||
ASSERT(HasDiffForUnsafe(countryId), ());
|
||||
return m_diffs.at(countryId);
|
||||
}
|
||||
|
||||
bool Manager::HasDiffFor(storage::TCountryId const & countryId) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return HasDiffForUnsafe(countryId);
|
||||
}
|
||||
|
||||
bool Manager::HasDiffForUnsafe(storage::TCountryId const & countryId) const
|
||||
{
|
||||
return m_diffs.find(countryId) != m_diffs.end();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ public:
|
|||
bool RemoveObserver(Observer const & observer) { return m_observers.Remove(observer); }
|
||||
|
||||
private:
|
||||
bool HasDiffForUnsafe(storage::TCountryId const & countryId) const;
|
||||
|
||||
mutable std::mutex m_mutex;
|
||||
Status m_status = Status::Undefined;
|
||||
NameFileInfoMap m_diffs;
|
||||
|
|
|
@ -120,7 +120,14 @@ NameFileInfoMap Checker::Check(LocalMapsInfo const & info)
|
|||
request.SetTimeout(kTimeoutInSeconds);
|
||||
NameFileInfoMap diffs;
|
||||
if (request.RunHttpRequest() && !request.WasRedirected() && request.ErrorCode() == 200)
|
||||
{
|
||||
diffs = DeserializeResponse(request.ServerResponse(), info.m_localMaps);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(LINFO, ("Request to diffs server failed. Code =", request.ErrorCode(),
|
||||
", Redirection =", request.WasRedirected()));
|
||||
}
|
||||
|
||||
return diffs;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue