summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-05-11 18:10:33 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-05-17 20:59:32 +0200
commit16b70040181ecf8bcbd4f0e505de0f77e518b160 (patch)
treed93c803e5404cc26a20c75bc6b6e569d5e729b26
parent0e784a933ae46a938ab47bd91ddb679b66237f3c (diff)
framework: fix lock assert in Job::execute()
include/osl/mutex.hxx:196: void osl::ClearableGuard<T>::clear() [with T = comphelper::SolarMutex]: Assertion `pT' failed. because clear() was called, then an exception was thrown and reset() was omitted. Change-Id: Iaa6d26e23261c2426eb3cc465b212752c4f454e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134195 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit ebbf4004d6061c3b31f9749bee06ef87afc5deb9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134179 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--framework/source/jobs/job.cxx25
1 files changed, 19 insertions, 6 deletions
diff --git a/framework/source/jobs/job.cxx b/framework/source/jobs/job.cxx
index 39b867ac3291..d2d9403e4ab2 100644
--- a/framework/source/jobs/job.cxx
+++ b/framework/source/jobs/job.cxx
@@ -156,6 +156,18 @@ void Job::setJobData( const JobData& aData )
void Job::execute( /*IN*/ const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs )
{
/* SAFE { */
+ class SolarMutexAntiGuard {
+ SolarMutexResettableGuard & m_rGuard;
+ public:
+ SolarMutexAntiGuard(SolarMutexResettableGuard & rGuard) : m_rGuard(rGuard)
+ {
+ m_rGuard.clear();
+ }
+ ~SolarMutexAntiGuard()
+ {
+ m_rGuard.reset();
+ }
+ };
SolarMutexResettableGuard aWriteLock;
// reject dangerous calls
@@ -191,23 +203,24 @@ void Job::execute( /*IN*/ const css::uno::Sequence< css::beans::NamedValue >& lD
if (xAJob.is())
{
m_aAsyncWait.reset();
- aWriteLock.clear();
+ SolarMutexAntiGuard const ag(aWriteLock);
/* } SAFE */
xAJob->executeAsync(lJobArgs, xThis);
// wait for finishing this job - so this method
// does the same for synchronous and asynchronous jobs!
m_aAsyncWait.wait();
- aWriteLock.reset();
/* SAFE { */
// Note: Result handling was already done inside the callback!
}
// execute it synchron
else if (xSJob.is())
{
- aWriteLock.clear();
- /* } SAFE */
- css::uno::Any aResult = xSJob->execute(lJobArgs);
- aWriteLock.reset();
+ css::uno::Any aResult;
+ {
+ SolarMutexAntiGuard const ag(aWriteLock);
+ /* } SAFE */
+ aResult = xSJob->execute(lJobArgs);
+ }
/* SAFE { */
impl_reactForJobResult(aResult);
}