From 14d942f16b284ca5180b29f3c912d158c0d0cdd0 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 4 Feb 2010 11:08:49 +0000 Subject: A flag+assert to help track bad behaviour in LLEventTimer, especially EXT-4754 --- indra/llcommon/lltimer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index ef3e8dbc94..63634117b5 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -565,19 +565,23 @@ LLEventTimer::LLEventTimer(F32 period) : mEventTimer() { mPeriod = period; + mBusy = false; } LLEventTimer::LLEventTimer(const LLDate& time) : mEventTimer() { mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch()); + mBusy = false; } LLEventTimer::~LLEventTimer() { + llassert(!mBusy); // this LLEventTimer was destroyed from its own tick() function - bad. } +//static void LLEventTimer::updateClass() { std::list completed_timers; @@ -587,10 +591,12 @@ void LLEventTimer::updateClass() F32 et = timer.mEventTimer.getElapsedTimeF32(); if (timer.mEventTimer.getStarted() && et > timer.mPeriod) { timer.mEventTimer.reset(); + timer.mBusy = true; if ( timer.tick() ) { completed_timers.push_back( &timer ); } + timer.mBusy = false; } } -- cgit v1.2.3 From 2c30ccf34d518ccedd0b3ffdeb2ba1da8d140a1d Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 4 Feb 2010 11:24:14 +0000 Subject: EXT-4754 Crash in LLEventTimer::updateClass --- indra/llcommon/lltimer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 63634117b5..21e165ebc9 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -578,7 +578,7 @@ LLEventTimer::LLEventTimer(const LLDate& time) LLEventTimer::~LLEventTimer() { - llassert(!mBusy); // this LLEventTimer was destroyed from its own tick() function - bad. + llassert(!mBusy); // this LLEventTimer was destroyed from within its own tick() function - bad. if you want tick() to cause destruction of its own timer, make it return true. } //static -- cgit v1.2.3 From ec076c97feaa2976520e28fd1c1b23099be656d7 Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Fri, 5 Feb 2010 18:15:31 -0800 Subject: EXT-4754 Fix for LLEventTimer::updateClass crash. Ugh. Update on Tofu's patch for this bug. Reviewed by Richard --- indra/llcommon/lltimer.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 21e165ebc9..900e122ea5 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -560,45 +560,44 @@ void secondsToTimecodeString(F32 current_time, std::string& tcstring) // LLEventTimer Implementation // ////////////////////////////////////////////////////////////////////////////// +bool LLEventTimer::sInTickLoop = false; LLEventTimer::LLEventTimer(F32 period) : mEventTimer() { mPeriod = period; - mBusy = false; } LLEventTimer::LLEventTimer(const LLDate& time) : mEventTimer() { mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch()); - mBusy = false; } LLEventTimer::~LLEventTimer() { - llassert(!mBusy); // this LLEventTimer was destroyed from within its own tick() function - bad. if you want tick() to cause destruction of its own timer, make it return true. + llassert(!LLEventTimer::sInTickLoop); // this LLEventTimer was destroyed from within its own tick() function - bad. if you want tick() to cause destruction of its own timer, make it return true. } //static void LLEventTimer::updateClass() { std::list completed_timers; + LLEventTimer::sInTickLoop = true; for (instance_iter iter = beginInstances(); iter != endInstances(); ) { LLEventTimer& timer = *iter++; F32 et = timer.mEventTimer.getElapsedTimeF32(); if (timer.mEventTimer.getStarted() && et > timer.mPeriod) { timer.mEventTimer.reset(); - timer.mBusy = true; if ( timer.tick() ) { completed_timers.push_back( &timer ); } - timer.mBusy = false; } } + LLEventTimer::sInTickLoop = false; if ( completed_timers.size() > 0 ) { -- cgit v1.2.3 From 4c7ae59996c2743152928abd81831a2ab5e788b6 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Sat, 6 Feb 2010 18:59:44 +0000 Subject: move LLEventTimer into its own source module. everyone includes it, almost no-one wants it. now I can dick with it a bit without rebuilding the world, at least. :) --- indra/llcommon/lltimer.cpp | 56 ---------------------------------------------- 1 file changed, 56 deletions(-) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 900e122ea5..25b768079b 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -555,59 +555,3 @@ void secondsToTimecodeString(F32 current_time, std::string& tcstring) } -////////////////////////////////////////////////////////////////////////////// -// -// LLEventTimer Implementation -// -////////////////////////////////////////////////////////////////////////////// -bool LLEventTimer::sInTickLoop = false; - -LLEventTimer::LLEventTimer(F32 period) -: mEventTimer() -{ - mPeriod = period; -} - -LLEventTimer::LLEventTimer(const LLDate& time) -: mEventTimer() -{ - mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch()); -} - - -LLEventTimer::~LLEventTimer() -{ - llassert(!LLEventTimer::sInTickLoop); // this LLEventTimer was destroyed from within its own tick() function - bad. if you want tick() to cause destruction of its own timer, make it return true. -} - -//static -void LLEventTimer::updateClass() -{ - std::list completed_timers; - LLEventTimer::sInTickLoop = true; - for (instance_iter iter = beginInstances(); iter != endInstances(); ) - { - LLEventTimer& timer = *iter++; - F32 et = timer.mEventTimer.getElapsedTimeF32(); - if (timer.mEventTimer.getStarted() && et > timer.mPeriod) { - timer.mEventTimer.reset(); - if ( timer.tick() ) - { - completed_timers.push_back( &timer ); - } - } - } - LLEventTimer::sInTickLoop = false; - - if ( completed_timers.size() > 0 ) - { - for (std::list::iterator completed_iter = completed_timers.begin(); - completed_iter != completed_timers.end(); - completed_iter++ ) - { - delete *completed_iter; - } - } -} - - -- cgit v1.2.3