diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-08-15 09:03:49 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-08-22 10:51:36 +0200 |
commit | 11403bc18ba1b7c7fd099e9b9aa0b61cefdd1287 (patch) | |
tree | 5b83929c3c485051514d270956b776066ca3df6b | |
parent | cb8bfa9a32799bcde4e960fa56e388d5f7b2a928 (diff) |
Abort on critical Scheduler problems
We don't have the possibility to continue processing tasks without
the scheduler lock. Same situation, if a task throws an exception.
In both cases we just abort() instead of using assertions.
Change-Id: I4d52a6ef0526a1e46b64f9f3a6e0cc1a718618cc
-rw-r--r-- | vcl/source/app/scheduler.cxx | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 0d3fb2f8ba0b..bdd5ad69d202 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -124,20 +124,23 @@ void Scheduler::ImplDeInitScheduler() void SchedulerMutex::acquire( sal_uInt32 nLockCount ) { + assert(nLockCount > 0); for (sal_uInt32 i = 0; i != nLockCount; ++i) { - bool ok = maMutex.acquire(); - assert(ok); (void) ok; - ++mnLockDepth; + if (!maMutex.acquire()) + abort(); } + mnLockDepth += nLockCount; } sal_uInt32 SchedulerMutex::release( bool bUnlockAll ) { - assert(mnLockDepth != 0); - sal_uInt32 nLockCount = bUnlockAll ? mnLockDepth : 1; + assert(mnLockDepth > 0); + const sal_uInt32 nLockCount = + (bUnlockAll || 0 == mnLockDepth) ? mnLockDepth : 1; mnLockDepth -= nLockCount; for (sal_uInt32 i = 0; i != nLockCount; ++i) { - maMutex.release(); + if (!maMutex.release()) + abort(); } return nLockCount; } @@ -373,7 +376,16 @@ next_entry: // not run a nested Scheduler loop and don't need a stack push! pMostUrgent->mbInScheduler = true; sal_uInt32 nLockCount = Unlock( true ); - pTask->Invoke(); + try + { + pTask->Invoke(); + } + catch (...) + { + SAL_WARN( "vcl.schedule", + "Uncaught exception during Task::Invoke()!" ); + abort(); + } Lock( nLockCount ); pMostUrgent->mbInScheduler = false; |