From 7cfcca87c6f9a9b280ab5e13ba92fff1830ee203 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 3 Sep 2012 13:25:31 +0200 Subject: Prevent a nullref if SimStatsReporter tries to report on a sim where psysics are not yet initialized --- .../Region/Framework/Scenes/SimStatsReporter.cs | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SimStatsReporter.cs') diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 20919a1..756b1f4 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -438,23 +438,26 @@ namespace OpenSim.Region.Framework.Scenes } // Extra statistics that aren't currently sent to clients - lock (m_lastReportedExtraSimStats) + if (m_scene.PhysicsScene != null) { - m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; - - Dictionary physicsStats = m_scene.PhysicsScene.GetStats(); - - if (physicsStats != null) + lock (m_lastReportedExtraSimStats) { - foreach (KeyValuePair tuple in physicsStats) + m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; + + Dictionary physicsStats = m_scene.PhysicsScene.GetStats(); + + if (physicsStats != null) { - // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second - // Need to change things so that stats source can indicate whether they are per second or - // per frame. - if (tuple.Key.EndsWith("MS")) - m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; - else - m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; + foreach (KeyValuePair tuple in physicsStats) + { + // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second + // Need to change things so that stats source can indicate whether they are per second or + // per frame. + if (tuple.Key.EndsWith("MS")) + m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; + else + m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; + } } } } -- cgit v1.1