Change WebStatsModule to check its config properly, instead of catching the ineviable NullReferenceException!

Also, tidy up spacing.
remove-scene-viewer
Justin Clark-Casey (justincc) 2011-10-05 23:31:53 +01:00
parent 9090039324
commit 604708fc96
1 changed files with 7 additions and 34 deletions

View File

@ -71,21 +71,13 @@ namespace OpenSim.Region.UserStatistics
public virtual void Initialise(Scene scene, IConfigSource config) public virtual void Initialise(Scene scene, IConfigSource config)
{ {
IConfig cnfg; IConfig cnfg = config.Configs["WebStats"];
try
{ if (cnfg != null)
cnfg = config.Configs["WebStats"];
enabled = cnfg.GetBoolean("enabled", false); enabled = cnfg.GetBoolean("enabled", false);
}
catch (Exception)
{
enabled = false;
}
if (!enabled) if (!enabled)
{
return; return;
}
lock (m_scene) lock (m_scene)
{ {
@ -115,16 +107,13 @@ namespace OpenSim.Region.UserStatistics
reports.Add("clients.report", clientReport); reports.Add("clients.report", clientReport);
reports.Add("sessions.report", sessionsReport); reports.Add("sessions.report", sessionsReport);
//// ////
// Add Your own Reports here (Do Not Modify Lines here Devs!) // Add Your own Reports here (Do Not Modify Lines here Devs!)
//// ////
//// ////
// End Own reports section // End Own reports section
//// ////
MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest); MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest);
MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
@ -265,7 +254,6 @@ namespace OpenSim.Region.UserStatistics
CreateTables(db); CreateTables(db);
} }
} }
} }
public void CreateTables(SqliteConnection db) public void CreateTables(SqliteConnection db)
@ -277,8 +265,6 @@ namespace OpenSim.Region.UserStatistics
createcmd.ExecuteNonQuery(); createcmd.ExecuteNonQuery();
} }
public virtual void PostInitialise() public virtual void PostInitialise()
{ {
if (!enabled) if (!enabled)
@ -376,15 +362,11 @@ namespace OpenSim.Region.UserStatistics
} }
} }
public void OnMakeChildAgent(ScenePresence agent) public void OnMakeChildAgent(ScenePresence agent)
{ {
} }
public void OnClientClosed(UUID agentID, Scene scene) public void OnClientClosed(UUID agentID, Scene scene)
{ {
lock (m_sessions) lock (m_sessions)
@ -394,7 +376,6 @@ namespace OpenSim.Region.UserStatistics
m_sessions.Remove(agentID); m_sessions.Remove(agentID);
} }
} }
} }
public string readLogLines(int amount) public string readLogLines(int amount)
@ -433,7 +414,6 @@ namespace OpenSim.Region.UserStatistics
fs.Close(); fs.Close();
fs.Dispose(); fs.Dispose();
return encoding.GetString(buffer); return encoding.GetString(buffer);
} }
public UUID GetRegionUUIDFromHandle(ulong regionhandle) public UUID GetRegionUUIDFromHandle(ulong regionhandle)
@ -448,6 +428,7 @@ namespace OpenSim.Region.UserStatistics
} }
return UUID.Zero; return UUID.Zero;
} }
/// <summary> /// <summary>
/// Callback for a viewerstats cap /// Callback for a viewerstats cap
/// </summary> /// </summary>
@ -523,8 +504,6 @@ namespace OpenSim.Region.UserStatistics
usd = uid.session_data; usd = uid.session_data;
if (message.Type != OSDType.Map) if (message.Type != OSDType.Map)
return new UserSessionID(); return new UserSessionID();
@ -699,7 +678,6 @@ namespace OpenSim.Region.UserStatistics
} }
} }
} }
#region SQL #region SQL
@ -824,6 +802,7 @@ set session_id=:session_id,
WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"; WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key";
#endregion #endregion
} }
public static class UserSessionUtil public static class UserSessionUtil
{ {
public static UserSessionData newUserSessionData() public static UserSessionData newUserSessionData()
@ -941,7 +920,6 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
return result / cnt; return result / cnt;
} }
public static float ArrayMode_f(float[] arr) public static float ArrayMode_f(float[] arr)
{ {
List<float> mode = new List<float>(); List<float> mode = new List<float>();
@ -995,10 +973,8 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
} }
return mode.ToArray()[0]; return mode.ToArray()[0];
} }
public static int ArrayMode_i(int[] arr) public static int ArrayMode_i(int[] arr)
{ {
List<int> mode = new List<int>(); List<int> mode = new List<int>();
@ -1052,7 +1028,6 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
} }
return mode.ToArray()[0]; return mode.ToArray()[0];
} }
#endregion #endregion
@ -1178,7 +1153,6 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
public List<float> _sim_fps; public List<float> _sim_fps;
public List<int> _agents_in_view; public List<int> _agents_in_view;
} }
#endregion #endregion
@ -1263,5 +1237,4 @@ WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"
m_scriptLinesPerSecond = stats.StatsBlock[20].StatValue; m_scriptLinesPerSecond = stats.StatsBlock[20].StatValue;
} }
} }
}
}