ucb/source/ucp/webdav-curl/SerfLockStore.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
New commits: commit d2e66d2c10b624033520a0c734851b9bed9a902a Author: Michael Stahl <mst...@redhat.com> AuthorDate: Wed May 29 21:18:29 2013 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Nov 1 18:24:01 2021 +0100 ucb: webdav-curl: NeonLockStore::stopTicker(): avoid deadlock Tor reports that NeonLockStore::stopTicker() m_pTickerThread->join() can deadlock with TickerThread running NeonLockStore::refreshLocks(). This can be avoided by copying m_pTickerThread to the stack, and releasing the m_aMutex before calling join(). [ port of commit 68ba2785c55eaa1ea70ce135bdad5322b0e04ed7 ] Change-Id: I6d2d993fd5315f27e6559a1e9034e961303fe894 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123180 Tested-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx index f25516d1742b..6380fe6e7447 100644 --- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx +++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx @@ -121,14 +121,21 @@ void SerfLockStore::startTicker() void SerfLockStore::stopTicker() { - osl::MutexGuard aGuard( m_aMutex ); - - if ( m_pTickerThread.is() ) + rtl::Reference<TickerThread> pTickerThread; { - m_pTickerThread->finish(); - m_pTickerThread->join(); + osl::MutexGuard aGuard( m_aMutex ); + + if (!m_pTickerThread.is()) + { + return; // nothing to do + } + m_pTickerThread->finish(); // needs mutex + // the TickerThread may run refreshLocks() at most once after this + pTickerThread = m_pTickerThread; m_pTickerThread.clear(); } + + pTickerThread->join(); // without m_aMutex locked (to prevent deadlock) } OUString SerfLockStore::getLockToken( const OUString& rLock )