Skip to content
Commit e2ef967c authored by Max Ramanouski's avatar Max Ramanouski Committed by Fushan Wen
Browse files

runners/calculator: implement thread-safety in QalculateEngine::evaluate

Libqalculate does not seem to support ability to run multiple computations
that are controlled or have timeout set beeing run in the same time.
After the timeout was introduced in QalculateEngine this led to BUG 470219,
which happens when computations are started from multiple threads in the same time
that "confuses" libqalculate computation thread which leads to crash in libqalculate code.

To fix that we need to ensure that only one evaluation is running at single moment of time.
This is done via QalculateLock class that is like QMutexLocker but for libqalculate.
QalculateLock is implemented with two static mutexes. Mutex s_evalLock is used
to ensure that only one evaluation is running at single moment.
Mutex s_ctrlLock is used to ensure that thread that aborted evaluation will
get to start next evaluation.

BUG: 470219


(cherry picked from commit 9d18e082)
parent f37802a9
Pipeline #413041 passed with stage
in 22 minutes and 4 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment