[Libreoffice-commits] core.git: comphelper/source
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Mon Nov 30 12:16:39 UTC 2020
comphelper/source/misc/threadpool.cxx | 7 +++++++
1 file changed, 7 insertions(+)
New commits:
commit af361b464b46dcc39a1bb4ab098a6ddf6ff40a53
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Nov 26 14:58:59 2020 +0100
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Nov 30 13:16:02 2020 +0100
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 at collabora.com>
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() );
More information about the Libreoffice-commits
mailing list