catch possible null refs

This commit is contained in:
UbitUmarov
2021-08-13 21:36:55 +01:00
parent cc86bdddcf
commit 4afc1e3909
3 changed files with 25 additions and 12 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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(