From 14d942f16b284ca5180b29f3c912d158c0d0cdd0 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Thu, 4 Feb 2010 11:08:49 +0000
Subject: [PATCH] A flag+assert to help track bad behaviour in LLEventTimer,
 especially EXT-4754

---
 indra/llcommon/lltimer.cpp | 6 ++++++
 indra/llcommon/lltimer.h   | 1 +
 2 files changed, 7 insertions(+)

diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index ef3e8dbc946..63634117b5f 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<LLEventTimer*> 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;
 		}
 	}
 
diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h
index d009c0f5f7d..4d995d5bba2 100644
--- a/indra/llcommon/lltimer.h
+++ b/indra/llcommon/lltimer.h
@@ -188,6 +188,7 @@ class LL_COMMON_API LLEventTimer : protected LLInstanceTracker<LLEventTimer>
 protected:
 	LLTimer mEventTimer;
 	F32 mPeriod;
+	bool mBusy;
 };
 
 U64 LL_COMMON_API totalTime();					// Returns current system time in microseconds
-- 
GitLab