diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-12-04 21:05:28 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-12-07 14:23:57 +0100 |
commit | e4b702718e83c1ad76f001e4d3641cc2dd17cd7b (patch) | |
tree | aeafb049de87bf3736ee8f7db98b87a6c625de4b /vcl | |
parent | dd5a1d31adbd43e81f7165c913ce474df74a85b7 (diff) |
Unlock scheduler in deinit for ProcessEventsToIdle
The scheduler is normally never locked when not processing its own
task lists. So while the fix is correct, that ProcessEventsToIdle
shouldn't run with a locked scheduler, just unlock it in the
actual shutdown case, where the deadlock occurred.
This also reverts commit 46f6b39c6d8acd064bafb2416feba757ba0d0fbc.
Change-Id: If1603c1563772dd1d156dc6d9bcddbf58aa721c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107241
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/README.scheduler | 11 | ||||
-rw-r--r-- | vcl/inc/schedulerimpl.hxx | 19 | ||||
-rw-r--r-- | vcl/source/app/scheduler.cxx | 3 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 1 |
4 files changed, 14 insertions, 20 deletions
diff --git a/vcl/README.scheduler b/vcl/README.scheduler index 52c76dac5b85..718509033e79 100644 --- a/vcl/README.scheduler +++ b/vcl/README.scheduler @@ -58,6 +58,17 @@ Task::mpSchedulerData, which is actually a part of the scheduler. Before invoking the task, we have to release the lock, so others can Start new Tasks. +The Scheduler just processes it's own Tasks in the main thread and needs +the SolarMutex for it and for DeInit (tested by DBG_TESTSOLARMUTEX). All +the other interaction just take the SchedulerMutex or don't need locking +at all. + +There is a "workaround" for static Task objecs, which would crash LO on +destruction, because Task::~Task would try to de-register itself in the +Scheduler, while the SchedulerLock would be long gone. OTOH this makes +Task handling less error-prone, than doing "special" manual cleanup. +There is also a "= TODOs and ideas =" to get rid if static Tasks. + = Lifecycle / thread-safety of Scheduler-based objects = diff --git a/vcl/inc/schedulerimpl.hxx b/vcl/inc/schedulerimpl.hxx index d95fb0157880..ffb08084252c 100644 --- a/vcl/inc/schedulerimpl.hxx +++ b/vcl/inc/schedulerimpl.hxx @@ -65,25 +65,6 @@ public: } }; -class SchedulerGuardReleaser final -{ -public: - SchedulerGuardReleaser() - { - Scheduler::Lock(); - m_nLockCount = Scheduler::Unlock(true) - 1; - } - - ~SchedulerGuardReleaser() - { - if (m_nLockCount) - Scheduler::Lock(m_nLockCount); - } - -private: - sal_uInt32 m_nLockCount; -}; - #endif // INCLUDED_VCL_INC_SCHEDULERIMPL_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index f9fc3dc01fc6..9ae60f3f344d 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -124,7 +124,10 @@ void Scheduler::ImplDeInitScheduler() "DeInit the scheduler - pending tasks: " << nTasks ); // clean up all the sfx::SfxItemDisruptor_Impl Idles + sal_uInt32 nLockCount = Unlock(true); + assert(1 == nLockCount); ProcessEventsToIdle(); + Lock(nLockCount); #endif rSchedCtx.mbActive = false; diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 0b30a0b6b688..f91375e77edd 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -462,7 +462,6 @@ bool Application::Reschedule( bool i_bAllEvents ) void Scheduler::ProcessEventsToIdle() { - SchedulerGuardReleaser aReleaser; int nSanity = 1; while( Application::Reschedule( true ) ) { |