From 17b6fc541bb3f7572301c4bab34d48bd0289ac2e Mon Sep 17 00:00:00 2001 From: paulc Date: Sun, 29 Aug 2010 12:25:19 +0000 Subject: [PATCH] Use a ListIterator to timerTick the components without holding the engine locked. Fixes a large number of deadlocks. git-svn-id: http://yate.null.ro/svn/yate/trunk@3560 acf43c95-373e-0410-b603-e72c3f656dc1 --- libs/ysig/engine.cpp | 19 +++++++------------ libs/ysig/yatesig.h | 1 - 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/libs/ysig/engine.cpp b/libs/ysig/engine.cpp index f9b2a6a3..d4af4e27 100644 --- a/libs/ysig/engine.cpp +++ b/libs/ysig/engine.cpp @@ -242,7 +242,7 @@ unsigned long SignallingComponent::tickSleep(unsigned long usec) const SignallingEngine::SignallingEngine(const char* name) : Mutex(true,"SignallingEngine"), - m_thread(0), m_listChanged(true), + m_thread(0), m_usecSleep(DEF_TICK_SLEEP), m_tickSleep(0) { debugName(name); @@ -438,18 +438,13 @@ unsigned long SignallingEngine::timerTick(const Time& when) { lock(); m_tickSleep = m_usecSleep; - m_listChanged = false; - for (ObjList* l = &m_components; l; l = l->next()) { - SignallingComponent* c = static_cast(l->get()); - if (c) { - c->timerTick(when); - // if the list was changed (can be only from this thread) we - // break out and get back later - cheaper than using a ListIterator - if (m_listChanged) - break; - } + ListIterator iter(m_components); + while (SignallingComponent* c = static_cast(iter.get())) { + unlock(); + c->timerTick(when); + lock(); } - unsigned long rval = m_listChanged ? 0 : m_tickSleep; + unsigned long rval = m_tickSleep; m_tickSleep = m_usecSleep; unlock(); return rval; diff --git a/libs/ysig/yatesig.h b/libs/ysig/yatesig.h index 41ac62a2..f63985b2 100644 --- a/libs/ysig/yatesig.h +++ b/libs/ysig/yatesig.h @@ -850,7 +850,6 @@ protected: private: SignallingThreadPrivate* m_thread; - bool m_listChanged; unsigned long m_usecSleep; unsigned long m_tickSleep; };