diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-05-29 21:18:29 +0200 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2013-05-31 13:44:41 +0200 |
commit | 54e101486be87d285f0dcce9f7a2aaca2535bc82 (patch) | |
tree | 47980dafc0803458a3a37a4c7f9441a82d2cfc94 | |
parent | b871339da4192afd68a4603efd5df424cb1796e1 (diff) |
ucb: 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().
Change-Id: I387f83a530c5b893f79fa677b1092e0902c8af65
(cherry picked from commit 68ba2785c55eaa1ea70ce135bdad5322b0e04ed7)
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonLockStore.cxx | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx index 77e62589f26f..c4d853332655 100644 --- a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx +++ b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx @@ -133,14 +133,21 @@ void NeonLockStore::startTicker() // ------------------------------------------------------------------- void NeonLockStore::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) } // ------------------------------------------------------------------- |