summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-05-29 21:18:29 +0200
committerTor Lillqvist <tlillqvist@suse.com>2013-05-30 07:44:39 +0300
commit47c45cee8642407c74e53d17ecfa9c49c54ce91f (patch)
tree4d05771a67d30f52c495de48f644984afde7a64a /ucb
parentf678e50744a70035f6d4f91f762c8fdbf4aa62d8 (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)
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav-neon/NeonLockStore.cxx17
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)
}
// -------------------------------------------------------------------