summaryrefslogtreecommitdiffstats
path: root/src/concurrent/qtconcurrentreducekernel.h
diff options
context:
space:
mode:
authorSona Kurazyan <[email protected]>2022-07-18 14:46:24 +0200
committerSona Kurazyan <[email protected]>2022-07-20 13:15:58 +0200
commit7afb093dd77f0ed9a1b4145d2d279810aba411c7 (patch)
treedd302828d9a45cc8dff301cc9769f2cb5fdeb236 /src/concurrent/qtconcurrentreducekernel.h
parent87fabf3e4b7a5ccc00a7b76b4098e2174e4514d8 (diff)
QtConcurrent::ReduceKernel: fix race conditions
resultsMapSize is modified inside the runReduce() method, and the writes are protected via mutex lock. However, reads of resultsMapSize through shouldThrottle()/shouldStartThread() (that can be called by multiple threads) are done without a lock. Added the missing locks. Task-number: QTBUG-104787 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I700e7b66e67025bc7f570bc8ad69409b82675049 Reviewed-by: Jarek Kobus <[email protected]> Reviewed-by: Marc Mutz <[email protected]>
Diffstat (limited to 'src/concurrent/qtconcurrentreducekernel.h')
-rw-r--r--src/concurrent/qtconcurrentreducekernel.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/concurrent/qtconcurrentreducekernel.h b/src/concurrent/qtconcurrentreducekernel.h
index a58739fc410..a2c693d9e2e 100644
--- a/src/concurrent/qtconcurrentreducekernel.h
+++ b/src/concurrent/qtconcurrentreducekernel.h
@@ -187,11 +187,13 @@ public:
inline bool shouldThrottle()
{
+ std::lock_guard<QMutex> locker(mutex);
return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
}
inline bool shouldStartThread()
{
+ std::lock_guard<QMutex> locker(mutex);
return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
}
};