Call Dispose() via using() on SqliteCommands in WebStatsModule after use.
parent
b18e410586
commit
1750fba9ce
|
@ -224,14 +224,12 @@ namespace OpenSim.Region.UserStatistics
|
||||||
concurrencyCounter--;
|
concurrencyCounter--;
|
||||||
|
|
||||||
response_code = 200;
|
response_code = 200;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strOut = MainServer.Instance.GetHTTP404("");
|
strOut = MainServer.Instance.GetHTTP404("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
responsedata["int_response_code"] = response_code;
|
responsedata["int_response_code"] = response_code;
|
||||||
responsedata["content_type"] = contenttype;
|
responsedata["content_type"] = contenttype;
|
||||||
responsedata["keepalive"] = false;
|
responsedata["keepalive"] = false;
|
||||||
|
@ -247,8 +245,8 @@ namespace OpenSim.Region.UserStatistics
|
||||||
// TODO: FIXME: implement stats migrations
|
// TODO: FIXME: implement stats migrations
|
||||||
const string SQL = @"SELECT * FROM migrations LIMIT 1";
|
const string SQL = @"SELECT * FROM migrations LIMIT 1";
|
||||||
|
|
||||||
SqliteCommand cmd = new SqliteCommand(SQL, db);
|
using (SqliteCommand cmd = new SqliteCommand(SQL, db))
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
@ -259,31 +257,32 @@ namespace OpenSim.Region.UserStatistics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void CreateTables(SqliteConnection db)
|
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.ExecuteNonQuery();
|
||||||
|
|
||||||
createcmd.CommandText = SQL_MIGRA_TABLE_CREATE;
|
createcmd.CommandText = SQL_MIGRA_TABLE_CREATE;
|
||||||
createcmd.ExecuteNonQuery();
|
createcmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void PostInitialise()
|
public virtual void PostInitialise()
|
||||||
{
|
{
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
AddHandlers();
|
AddHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Close()
|
public virtual void Close()
|
||||||
{
|
{
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
dbConn.Close();
|
dbConn.Close();
|
||||||
dbConn.Dispose();
|
dbConn.Dispose();
|
||||||
m_sessions.Clear();
|
m_sessions.Clear();
|
||||||
|
@ -304,7 +303,8 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
public void OnRegisterCaps(UUID agentID, Caps caps)
|
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();
|
string capsPath = "/CAPS/VS/" + UUID.Random();
|
||||||
caps.RegisterHandler("ViewerStats",
|
caps.RegisterHandler("ViewerStats",
|
||||||
new RestStreamHandler("POST", capsPath,
|
new RestStreamHandler("POST", capsPath,
|
||||||
|
@ -318,7 +318,6 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
public void OnDeRegisterCaps(UUID agentID, Caps caps)
|
public void OnDeRegisterCaps(UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddHandlers()
|
protected virtual void AddHandlers()
|
||||||
|
@ -368,7 +367,6 @@ 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)
|
||||||
|
@ -430,6 +428,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
return scene.RegionInfo.RegionID;
|
return scene.RegionInfo.RegionID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return UUID.Zero;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,14 +457,14 @@ namespace OpenSim.Region.UserStatistics
|
||||||
UserSessionData usd;
|
UserSessionData usd;
|
||||||
OSD message = OSDParser.DeserializeLLSDXml(request);
|
OSD message = OSDParser.DeserializeLLSDXml(request);
|
||||||
OSDMap mmap;
|
OSDMap mmap;
|
||||||
|
|
||||||
lock (m_sessions)
|
lock (m_sessions)
|
||||||
{
|
{
|
||||||
if (agentID != UUID.Zero)
|
if (agentID != UUID.Zero)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!m_sessions.ContainsKey(agentID))
|
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();
|
return new UserSessionID();
|
||||||
}
|
}
|
||||||
uid = m_sessions[agentID];
|
uid = m_sessions[agentID];
|
||||||
|
@ -585,8 +584,6 @@ namespace OpenSim.Region.UserStatistics
|
||||||
usd.n_out_kb = (float)net_out["kbytes"].AsReal();
|
usd.n_out_kb = (float)net_out["kbytes"].AsReal();
|
||||||
usd.n_out_pk = net_out["packets"].AsInteger();
|
usd.n_out_pk = net_out["packets"].AsInteger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +599,8 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
lock (db)
|
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(":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(":agent_id", uid.session_data.agent_id.ToString()));
|
||||||
updatecmd.Parameters.Add(new SqliteParameter(":region_id", uid.session_data.region_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(":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(":agent_key", uid.session_data.agent_id.ToString()));
|
||||||
updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_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();
|
int result = updatecmd.ExecuteNonQuery();
|
||||||
|
|
||||||
if (result == 0)
|
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;
|
updatecmd.CommandText = SQL_STATS_TABLE_INSERT;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
updatecmd.ExecuteNonQuery();
|
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue