From cc92e121b9278a0593fec9091b097e4f32d64d6c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 9 Sep 2010 13:43:25 +0000 Subject: Break deadlock caused when ClusterTimer::drop is called concurrently with Timer::add. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@995426 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/cluster/Cluster.cpp | 1 - cpp/src/qpid/sys/Timer.cpp | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp index df0e612af7..5da1579cb7 100644 --- a/cpp/src/qpid/cluster/Cluster.cpp +++ b/cpp/src/qpid/cluster/Cluster.cpp @@ -1126,7 +1126,6 @@ void Cluster::timerDrop(const MemberId& , const std::string& name, Lock&) { } bool Cluster::isElder() const { - Monitor::ScopedLock l(lock); return elder; } diff --git a/cpp/src/qpid/sys/Timer.cpp b/cpp/src/qpid/sys/Timer.cpp index 3b627687de..76e8b3dc0b 100644 --- a/cpp/src/qpid/sys/Timer.cpp +++ b/cpp/src/qpid/sys/Timer.cpp @@ -107,16 +107,19 @@ void Timer::run() { ScopedLock l(t->callbackLock); if (t->cancelled) { - drop(t); + { + Monitor::ScopedUnlock u(monitor); + drop(t); + } if (delay > lateCancel) { - QPID_LOG(debug, t->name << " cancelled timer woken up " << delay / TIME_MSEC - << "ms late"); + QPID_LOG(debug, t->name << " cancelled timer woken up " << + delay / TIME_MSEC << "ms late"); } continue; } else if(Duration(t->nextFireTime, start) >= 0) { { - Monitor::ScopedUnlock u(monitor); - fire(t); + Monitor::ScopedUnlock u(monitor); + fire(t); } // Warn if callback overran next timer's start. AbsTime end(AbsTime::now()); -- cgit v1.2.1