diff --git a/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs b/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs index 55ddf0681c..ea04583cb2 100644 --- a/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs +++ b/OpenSim/Framework/Monitoring/Stats/PercentageStat.cs @@ -45,16 +45,23 @@ namespace OpenSim.Framework.Monitoring // Asking for an update here means that the updater cannot access this value without infinite recursion. // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being // called by the pull action and just return the value. - if (StatType == StatType.Pull) - PullAction(this); + try + { + if (StatType == StatType.Pull) + PullAction(this); - long c = Consequent; + long c = Consequent; - // Avoid any chance of a multi-threaded divide-by-zero - if (c == 0) + // Avoid any chance of a multi-threaded divide-by-zero + if (c == 0) + return 0; + + return (double)Antecedent / c * 100; + } + catch + { return 0; - - return (double)Antecedent / c * 100; + } } set diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index cb92c2e06d..97c76f922f 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs @@ -81,12 +81,18 @@ namespace OpenSim.Framework.Monitoring // Asking for an update here means that the updater cannot access this value without infinite recursion. // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being // called by the pull action and just return the value. - if (StatType == StatType.Pull) - PullAction(this); + try + { + if (StatType == StatType.Pull) + PullAction(this); - return m_value; + return m_value; + } + catch + { + return 0; + } } - set { m_value = value; diff --git a/OpenSim/Framework/Monitoring/WorkManager.cs b/OpenSim/Framework/Monitoring/WorkManager.cs index b709ab0e8e..acf2471dc0 100755 --- a/OpenSim/Framework/Monitoring/WorkManager.cs +++ b/OpenSim/Framework/Monitoring/WorkManager.cs @@ -69,7 +69,7 @@ namespace OpenSim.Framework.Monitoring "jobengine", StatType.Pull, MeasuresOfInterest.None, - stat => stat.Value = JobEngine.JobsWaiting, + stat => stat.Value = JobEngine == null ? 0 : JobEngine.JobsWaiting, StatVerbosity.Debug)); MainConsole.Instance.Commands.AddCommand(