diff options
author | Patrick Luby <guibmacdev@gmail.com> | 2024-04-03 17:34:49 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-04-15 12:36:22 +0200 |
commit | 1e9e1298291b48c289bbc07c9997f54951802a4a (patch) | |
tree | 5167f3cdafd3a5a4d6fed5fbd9876dbed1a665b5 /desktop | |
parent | 809b60325ee2f720702925754b371512446729a7 (diff) |
tdf#159790 temporarily release mutex for child packages
This code is normally run on a separate thread so if a
child package tries to acquire the solar mutex, a deadlock
can occur if the main thread calls isRegistered() on this
package or any of its parents. So, temporarily release
this package's mutex while registering the child package.
Change-Id: I45b534c44d5946637a5441927ed01a68aad4c448
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165766
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit cab028121bd9b620529b6492b3247ac48ac2082b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165831
Reviewed-by: Patrick Luby <guibomacdev@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/deployment/registry/package/dp_package.cxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 6af2fb5515f5..d5c1feeb4992 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -781,7 +781,7 @@ uno::Reference< graphic::XGraphic > BackendImpl::PackageImpl::getIcon( sal_Bool void BackendImpl::PackageImpl::processPackage_( - ::osl::ResettableMutexGuard &, + ::osl::ResettableMutexGuard & guard, bool doRegisterPackage, bool startup, ::rtl::Reference<AbortChannel> const & abortChannel, @@ -802,10 +802,20 @@ void BackendImpl::PackageImpl::processPackage_( xPackage->createAbortChannel() ); AbortChannel::Chain chain( abortChannel, xSubAbortChannel ); try { + // tdf#159790 temporarily release mutex for child packages + // This code is normally run on a separate thread so if a + // child package tries to acquire the solar mutex, a deadlock + // can occur if the main thread calls isRegistered() on this + // package or any of its parents. So, temporarily release + // this package's mutex while registering the child package. + guard.clear(); xPackage->registerPackage( startup, xSubAbortChannel, xCmdEnv ); + guard.reset(); } catch (const Exception &) { + guard.reset(); + //We even try a rollback if the user cancelled the action (CommandAbortedException) //in order to prevent invalid database entries. Any exc( ::cppu::getCaughtException() ); @@ -856,6 +866,11 @@ void BackendImpl::PackageImpl::processPackage_( ::cppu::throwException(exc); } } + catch (...) { + guard.reset(); + throw; + } + data.items.emplace_back(xPackage->getURL(), xPackage->getPackageType()->getMediaType()); } |