From ca37317a1473bb79ef8de4f683231700cb9e062c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 30 Nov 2012 15:48:22 -0800
Subject: [PATCH] SH-3406 WIP convert fast timers to lltrace system fixed crash
 when sending viewer asset stats

---
 indra/llcommon/lltracerecording.cpp  | 13 +++++++++----
 indra/llcommon/lltracerecording.h    |  2 ++
 indra/newview/llappviewer.cpp        |  2 +-
 indra/newview/llviewerassetstats.cpp | 11 ++++++++++-
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index e7ed55e8aef..e31e36cb27b 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -58,10 +58,6 @@ Recording::Recording( const Recording& other )
 	mStackTimers       = other.mStackTimers;
 
 	LLStopWatchControlsMixin::initTo(other.getPlayState());
-	if (other.isStarted())
-	{
-		handleStart();
-	}
 }
 
 
@@ -127,6 +123,15 @@ bool Recording::isPrimary() const
 	return mCounts->isPrimary();
 }
 
+void Recording::makeUnique()
+{
+	mCountsFloat.makeUnique();
+	mMeasurementsFloat.makeUnique();
+	mCounts.makeUnique();
+	mMeasurements.makeUnique();
+	mStackTimers.makeUnique();
+}
+
 void Recording::appendRecording( const Recording& other )
 {
 	mCountsFloat.write()->addSamples(*other.mCountsFloat);
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index efc54d240fb..e5a21a2d382 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -112,6 +112,8 @@ namespace LLTrace
 		void makePrimary();
 		bool isPrimary() const;
 
+		void makeUnique();
+
 		void appendRecording(const Recording& other);
 
 		void update();
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 713ae789a7d..fb95c9ec5b2 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -438,7 +438,7 @@ LLAppViewer::LLUpdaterInfo *LLAppViewer::sUpdaterInfo = NULL ;
 //----------------------------------------------------------------------------
 // Metrics logging control constants
 //----------------------------------------------------------------------------
-static const F32 METRICS_INTERVAL_DEFAULT = 30.0;
+static const F32 METRICS_INTERVAL_DEFAULT = 600.0;
 static const F32 METRICS_INTERVAL_QA = 30.0;
 static F32 app_metrics_interval = METRICS_INTERVAL_DEFAULT;
 static bool app_metrics_qa_mode = false;
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index d79d98aaaf0..58936c32208 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -250,9 +250,18 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 {
 	src.mCurRecording->update();
 	mRegionRecordings = src.mRegionRecordings;
-	
+
 	mCurRecording = &mRegionRecordings[mRegionHandle];
 	mCurRecording->stop();
+
+	// assume this is being passed to another thread, so make sure we have unique copies of recording data
+	for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end();
+		it != end_it;
+		++it)
+	{
+		it->second.makeUnique();
+	}
+
 	LLStopWatchControlsMixin::initTo(src.getPlayState());
 }
 
-- 
GitLab