diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-11-26 14:58:59 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-12-01 11:15:08 +0100 |
commit | ba8156d5a1dd2d37c7daef15f48b988bf6ded7a7 (patch) | |
tree | 455498f4dc2f88d7ad9e617f7e6d06f515cf0b5e /comphelper | |
parent | tdf#138483 sc: update red circles after merging cells (diff) | |
download | core-ba8156d5a1dd2d37c7daef15f48b988bf6ded7a7.tar.gz core-ba8156d5a1dd2d37c7daef15f48b988bf6ded7a7.zip |
handle a possible (unlikely?) deadlock in threadpool cleanup
Change-Id: I4886989816662bad50db145fd1ff1466e8a3a140
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106700
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit af361b464b46dcc39a1bb4ab098a6ddf6ff40a53)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106823
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/threadpool.cxx | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx index 3c335e7f4761..4ff7bac3aede 100644 --- a/comphelper/source/misc/threadpool.cxx +++ b/comphelper/source/misc/threadpool.cxx @@ -167,7 +167,14 @@ void ThreadPool::shutdownLocked(std::unique_lock<std::mutex>& aGuard) else { while( !maTasks.empty() ) + { maTasksChanged.wait( aGuard ); + // In the (unlikely but possible?) case pushTask() gets called meanwhile, + // its notify_one() call is meant to wake a up a thread and process the task. + // But if this code gets woken up instead, it could lead to a deadlock. + // Pass on the notification. + maTasksChanged.notify_one(); + } } assert( maTasks.empty() ); |