summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-11-26 14:58:59 +0100
committerLuboš Luňák <l.lunak@collabora.com>2020-11-30 13:16:02 +0100
commitaf361b464b46dcc39a1bb4ab098a6ddf6ff40a53 (patch)
tree3f2e760d13b4786936aa546116bbe38c366239ed /comphelper
parent8332d6d8200e8ca1f22dd98d9373efd5a431d09c (diff)
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>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/threadpool.cxx7
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() );