From a73ffc25c3c3f331f6daa43dfd4086d63566c5cc Mon Sep 17 00:00:00 2001 From: elsid Date: Mon, 17 May 2021 17:44:26 +0200 Subject: [PATCH] Add missing synchronization for present tiles modification insert/erase can be done from multiple threads simultaneously. mMutex is already used to synchronize reads so use it for writes too. --- components/detournavigator/asyncnavmeshupdater.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/detournavigator/asyncnavmeshupdater.cpp b/components/detournavigator/asyncnavmeshupdater.cpp index bee4510b4..11de60745 100644 --- a/components/detournavigator/asyncnavmeshupdater.cpp +++ b/components/detournavigator/asyncnavmeshupdater.cpp @@ -298,9 +298,15 @@ namespace DetourNavigator } if (status == UpdateNavMeshStatus::removed || status == UpdateNavMeshStatus::lost) + { + const std::scoped_lock lock(mMutex); mPresentTiles.erase(std::make_tuple(job.mAgentHalfExtents, job.mChangedTile)); + } else if (isSuccess(status) && status != UpdateNavMeshStatus::ignored) + { + const std::scoped_lock lock(mMutex); mPresentTiles.insert(std::make_tuple(job.mAgentHalfExtents, job.mChangedTile)); + } const auto finish = std::chrono::steady_clock::now();