diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-05-30 17:13:50 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-05-30 17:24:38 +0200 |
commit | 13b60fd80a7adfb0ef81a818917cfec5edfc6edc (patch) | |
tree | 832b1a43c9577f2643a3c166c6d3821d17d1c2d9 /ucb | |
parent | 40ae8f365b2c30a37a9fb22aabd4858f519665ed (diff) |
ucb: NeonLockStore::stopTicker(): really avoid deadlock
Follow up on 68ba2785c55eaa1ea70ce135bdad5322b0e04ed7, which missed the
sad fact that m_aMutex is locked recursively.
Avoid that by passing a ClearableMutexGuard to stopTicker() and
unlocking that. Also lock m_aMutex in the destructor while at it.
Change-Id: I5ef7ef8f15e2b5c9810c5ffc64ed922ab9ad2807
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonLockStore.cxx | 23 | ||||
-rw-r--r-- | ucb/source/ucp/webdav-neon/NeonLockStore.hxx | 2 |
2 files changed, 13 insertions, 12 deletions
diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx index 043ea7d27d72..890402c6a1a4 100644 --- a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx +++ b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx @@ -93,7 +93,9 @@ NeonLockStore::NeonLockStore() NeonLockStore::~NeonLockStore() { - stopTicker(); + osl::ResettableMutexGuard aGuard(m_aMutex); + stopTicker(aGuard); + aGuard.reset(); // actually no threads should even try to access members now // release active locks, if any. OSL_ENSURE( m_aLockInfoMap.empty(), @@ -126,23 +128,22 @@ void NeonLockStore::startTicker() } } -void NeonLockStore::stopTicker() +void NeonLockStore::stopTicker(osl::ClearableMutexGuard & rGuard) { rtl::Reference<TickerThread> pTickerThread; - { - osl::MutexGuard aGuard( m_aMutex ); - if (!m_pTickerThread.is()) - { - return; // nothing to do - } + if (m_pTickerThread.is()) + { 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) + rGuard.clear(); + + if (pTickerThread.is()) + pTickerThread->join(); // without m_aMutex locked (to prevent deadlock) } void NeonLockStore::registerSession( HttpSession * pHttpSession ) @@ -193,13 +194,13 @@ void NeonLockStore::updateLock( NeonLock * pLock, void NeonLockStore::removeLock( NeonLock * pLock ) { - osl::MutexGuard aGuard( m_aMutex ); + osl::ClearableMutexGuard aGuard( m_aMutex ); m_aLockInfoMap.erase( pLock ); ne_lockstore_remove( m_pNeonLockStore, pLock ); if ( m_aLockInfoMap.empty() ) - stopTicker(); + stopTicker(aGuard); } void NeonLockStore::refreshLocks() diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.hxx b/ucb/source/ucp/webdav-neon/NeonLockStore.hxx index dd9b18599505..529158e588b7 100644 --- a/ucb/source/ucp/webdav-neon/NeonLockStore.hxx +++ b/ucb/source/ucp/webdav-neon/NeonLockStore.hxx @@ -96,7 +96,7 @@ public: private: void startTicker(); - void stopTicker(); + void stopTicker(osl::ClearableMutexGuard & rGuard); }; } // namespace webdav_ucp |