mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-27 16:54:52 +01:00
Apply better guards for download queueing (#8864)
Follow-up to #8821. Use mutex to synchronize access rather than make the bool atomic to avoid TOCTOU issues.
This commit is contained in:
committed by
Ted John
parent
9f2e1d7450
commit
dff1ebaf21
@@ -34,6 +34,7 @@ private:
|
||||
std::vector<rct_object_entry> _downloadedEntries;
|
||||
size_t _currentDownloadIndex{};
|
||||
std::mutex _downloadedEntriesMutex;
|
||||
std::mutex _queueMutex;
|
||||
bool _nextDownloadQueued{};
|
||||
|
||||
// TODO static due to INTENT_EXTRA_CALLBACK not allowing a std::function
|
||||
@@ -61,6 +62,7 @@ public:
|
||||
|
||||
void Update()
|
||||
{
|
||||
std::lock_guard guard(_queueMutex);
|
||||
if (_nextDownloadQueued)
|
||||
{
|
||||
_nextDownloadQueued = false;
|
||||
@@ -87,6 +89,7 @@ private:
|
||||
|
||||
void QueueNextDownload()
|
||||
{
|
||||
std::lock_guard guard(_queueMutex);
|
||||
_nextDownloadQueued = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user