Call Dispose() via using() on SqliteCommands in WebStatsModule after use.

0.7.3-post-fixes
Justin Clark-Casey (justincc) 2012-02-28 22:54:21 +00:00
parent b18e410586
commit 1750fba9ce
1 changed files with 99 additions and 100 deletions

View File

@ -224,14 +224,12 @@ namespace OpenSim.Region.UserStatistics
concurrencyCounter--;
response_code = 200;
}
else
{
strOut = MainServer.Instance.GetHTTP404("");
}
responsedata["int_response_code"] = response_code;
responsedata["content_type"] = contenttype;
responsedata["keepalive"] = false;
@ -247,8 +245,8 @@ namespace OpenSim.Region.UserStatistics
// TODO: FIXME: implement stats migrations
const string SQL = @"SELECT * FROM migrations LIMIT 1";
SqliteCommand cmd = new SqliteCommand(SQL, db);
using (SqliteCommand cmd = new SqliteCommand(SQL, db))
{
try
{
cmd.ExecuteNonQuery();
@ -259,31 +257,32 @@ namespace OpenSim.Region.UserStatistics
}
}
}
}
public void CreateTables(SqliteConnection db)
{
SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db);
using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db))
{
createcmd.ExecuteNonQuery();
createcmd.CommandText = SQL_MIGRA_TABLE_CREATE;
createcmd.ExecuteNonQuery();
}
}
public virtual void PostInitialise()
{
if (!enabled)
{
return;
}
AddHandlers();
}
public virtual void Close()
{
if (!enabled)
{
return;
}
dbConn.Close();
dbConn.Dispose();
m_sessions.Clear();
@ -304,7 +303,8 @@ namespace OpenSim.Region.UserStatistics
public void OnRegisterCaps(UUID agentID, Caps caps)
{
m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
// m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
string capsPath = "/CAPS/VS/" + UUID.Random();
caps.RegisterHandler("ViewerStats",
new RestStreamHandler("POST", capsPath,
@ -318,7 +318,6 @@ namespace OpenSim.Region.UserStatistics
public void OnDeRegisterCaps(UUID agentID, Caps caps)
{
}
protected virtual void AddHandlers()
@ -368,7 +367,6 @@ namespace OpenSim.Region.UserStatistics
public void OnMakeChildAgent(ScenePresence agent)
{
}
public void OnClientClosed(UUID agentID, Scene scene)
@ -430,6 +428,7 @@ namespace OpenSim.Region.UserStatistics
return scene.RegionInfo.RegionID;
}
}
return UUID.Zero;
}
@ -458,14 +457,14 @@ namespace OpenSim.Region.UserStatistics
UserSessionData usd;
OSD message = OSDParser.DeserializeLLSDXml(request);
OSDMap mmap;
lock (m_sessions)
{
if (agentID != UUID.Zero)
{
if (!m_sessions.ContainsKey(agentID))
{
m_log.Warn("[WEB STATS MODULE]: no session for stat disclosure");
m_log.WarnFormat("[WEB STATS MODULE]: no session for stat disclosure for agent {0}", agentID);
return new UserSessionID();
}
uid = m_sessions[agentID];
@ -585,8 +584,6 @@ namespace OpenSim.Region.UserStatistics
usd.n_out_kb = (float)net_out["kbytes"].AsReal();
usd.n_out_pk = net_out["packets"].AsInteger();
}
}
}
@ -602,7 +599,8 @@ namespace OpenSim.Region.UserStatistics
lock (db)
{
SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db);
using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db))
{
updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString()));
updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString()));
updatecmd.Parameters.Add(new SqliteParameter(":region_id", uid.session_data.region_id.ToString()));
@ -658,27 +656,28 @@ namespace OpenSim.Region.UserStatistics
updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString()));
updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString()));
updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString()));
// m_log.Debug("UPDATE");
// m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id);
int result = updatecmd.ExecuteNonQuery();
if (result == 0)
{
// m_log.Debug("INSERT");
// m_log.DebugFormat("[WEB STATS MODULE]: Database stats insert for {0}", uid.session_data.agent_id);
updatecmd.CommandText = SQL_STATS_TABLE_INSERT;
try
{
updatecmd.ExecuteNonQuery();
}
catch (SqliteExecutionException)
catch (Exception e)
{
m_log.Warn("[WEB STATS MODULE]: failed to write stats to storage Execution Exception");
m_log.WarnFormat(
"[WEB STATS MODULE]: failed to write stats for {0}, storage Execution Exception {1}{2}",
uid.session_data.agent_id, e.Message, e.StackTrace);
}
catch (SqliteSyntaxException)
{
m_log.Warn("[WEB STATS MODULE]: failed to write stats to storage SQL Syntax Exception");
}
}
}
}