From 9de991301cfcb66721a5593dd9098fe84e090dec Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 6 Oct 2012 04:03:53 +0100
Subject: Make UserSessionID a class rather than a struct, so that later
updates to value suceed (rather than having to pull the data out and reinsert
back into the Dictionary).
Fixes http://opensimulator.org/mantis/view.php?id=6338
---
OpenSim/Region/UserStatistics/WebStatsModule.cs | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/UserStatistics')
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index c11ea02..b1795db 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -319,6 +319,10 @@ namespace OpenSim.Region.UserStatistics
private void OnMakeRootAgent(ScenePresence agent)
{
+// m_log.DebugFormat(
+// "[WEB STATS MODULE]: Looking for session {0} for {1} in {2}",
+// agent.ControllingClient.SessionId, agent.Name, agent.Scene.Name);
+
lock (m_sessions)
{
UserSessionID uid;
@@ -427,7 +431,10 @@ namespace OpenSim.Region.UserStatistics
m_log.WarnFormat("[WEB STATS MODULE]: no session for stat disclosure for agent {0}", agentID);
return new UserSessionID();
}
+
uid = m_sessions[agentID];
+
+// m_log.DebugFormat("[WEB STATS MODULE]: Got session {0} for {1}", uid.session_id, agentID);
}
else
{
@@ -499,6 +506,7 @@ namespace OpenSim.Region.UserStatistics
usd.d_texture_kb = (float)downloads_map["texture_kbytes"].AsReal();
usd.d_world_kb = (float)downloads_map["workd_kbytes"].AsReal();
+// m_log.DebugFormat("[WEB STATS MODULE]: mmap[\"session_id\"] = [{0}]", mmap["session_id"].AsUUID());
usd.session_id = mmap["session_id"].AsUUID();
@@ -549,11 +557,18 @@ namespace OpenSim.Region.UserStatistics
uid.session_data = usd;
m_sessions[agentID] = uid;
+
+// m_log.DebugFormat(
+// "[WEB STATS MODULE]: Parse data for {0} {1}, session {2}", uid.name_f, uid.name_l, uid.session_id);
+
return uid;
}
private void UpdateUserStats(UserSessionID uid, SqliteConnection db)
{
+// m_log.DebugFormat(
+// "[WEB STATS MODULE]: Updating user stats for {0} {1}, session {2}", uid.name_f, uid.name_l, uid.session_id);
+
if (uid.session_id == UUID.Zero)
return;
@@ -740,7 +755,6 @@ VALUES
s.min_ping = ArrayMin_f(__ping);
s.max_ping = ArrayMax_f(__ping);
s.mode_ping = ArrayMode_f(__ping);
-
}
#region Statistics
@@ -985,7 +999,7 @@ VALUES
}
#region structs
- public struct UserSessionID
+ public class UserSessionID
{
public UUID session_id;
public UUID region_id;
--
cgit v1.1
From 13c4fd7271783d3e2c51da7b9509d08aeedf3131 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 6 Oct 2012 04:06:27 +0100
Subject: refactor: Rename UserSessioNID -> UserSession in WebStatsModule since
this is what it actually represents
---
OpenSim/Region/UserStatistics/WebStatsModule.cs | 40 ++++++++++++-------------
1 file changed, 20 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/UserStatistics')
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index b1795db..625eba4 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.UserStatistics
///
/// User statistics sessions keyed by agent ID
///
- private Dictionary m_sessions = new Dictionary();
+ private Dictionary m_sessions = new Dictionary();
private List m_scenes = new List();
private Dictionary reports = new Dictionary();
@@ -325,12 +325,12 @@ namespace OpenSim.Region.UserStatistics
lock (m_sessions)
{
- UserSessionID uid;
+ UserSession uid;
if (!m_sessions.ContainsKey(agent.UUID))
{
UserSessionData usd = UserSessionUtil.newUserSessionData();
- uid = new UserSessionID();
+ uid = new UserSession();
uid.name_f = agent.Firstname;
uid.name_l = agent.Lastname;
uid.session_data = usd;
@@ -415,9 +415,9 @@ namespace OpenSim.Region.UserStatistics
return String.Empty;
}
- private UserSessionID ParseViewerStats(string request, UUID agentID)
+ private UserSession ParseViewerStats(string request, UUID agentID)
{
- UserSessionID uid = new UserSessionID();
+ UserSession uid = new UserSession();
UserSessionData usd;
OSD message = OSDParser.DeserializeLLSDXml(request);
OSDMap mmap;
@@ -429,7 +429,7 @@ namespace OpenSim.Region.UserStatistics
if (!m_sessions.ContainsKey(agentID))
{
m_log.WarnFormat("[WEB STATS MODULE]: no session for stat disclosure for agent {0}", agentID);
- return new UserSessionID();
+ return new UserSession();
}
uid = m_sessions[agentID];
@@ -440,14 +440,14 @@ namespace OpenSim.Region.UserStatistics
{
// parse through the beginning to locate the session
if (message.Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
mmap = (OSDMap)message;
{
UUID sessionID = mmap["session_id"].AsUUID();
if (sessionID == UUID.Zero)
- return new UserSessionID();
+ return new UserSession();
// search through each session looking for the owner
@@ -466,7 +466,7 @@ namespace OpenSim.Region.UserStatistics
// can't find a session
if (agentID == UUID.Zero)
{
- return new UserSessionID();
+ return new UserSession();
}
}
}
@@ -475,12 +475,12 @@ namespace OpenSim.Region.UserStatistics
usd = uid.session_data;
if (message.Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
mmap = (OSDMap)message;
{
if (mmap["agent"].Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
OSDMap agent_map = (OSDMap)mmap["agent"];
usd.agent_id = agentID;
usd.name_f = uid.name_f;
@@ -500,7 +500,7 @@ namespace OpenSim.Region.UserStatistics
(float)agent_map["fps"].AsReal());
if (mmap["downloads"].Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
OSDMap downloads_map = (OSDMap)mmap["downloads"];
usd.d_object_kb = (float)downloads_map["object_kbytes"].AsReal();
usd.d_texture_kb = (float)downloads_map["texture_kbytes"].AsReal();
@@ -511,7 +511,7 @@ namespace OpenSim.Region.UserStatistics
usd.session_id = mmap["session_id"].AsUUID();
if (mmap["system"].Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
OSDMap system_map = (OSDMap)mmap["system"];
usd.s_cpu = system_map["cpu"].AsString();
@@ -520,13 +520,13 @@ namespace OpenSim.Region.UserStatistics
usd.s_ram = system_map["ram"].AsInteger();
if (mmap["stats"].Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
OSDMap stats_map = (OSDMap)mmap["stats"];
{
if (stats_map["failures"].Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
OSDMap stats_failures = (OSDMap)stats_map["failures"];
usd.f_dropped = stats_failures["dropped"].AsInteger();
usd.f_failed_resends = stats_failures["failed_resends"].AsInteger();
@@ -535,18 +535,18 @@ namespace OpenSim.Region.UserStatistics
usd.f_send_packet = stats_failures["send_packet"].AsInteger();
if (stats_map["net"].Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
OSDMap stats_net = (OSDMap)stats_map["net"];
{
if (stats_net["in"].Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
OSDMap net_in = (OSDMap)stats_net["in"];
usd.n_in_kb = (float)net_in["kbytes"].AsReal();
usd.n_in_pk = net_in["packets"].AsInteger();
if (stats_net["out"].Type != OSDType.Map)
- return new UserSessionID();
+ return new UserSession();
OSDMap net_out = (OSDMap)stats_net["out"];
usd.n_out_kb = (float)net_out["kbytes"].AsReal();
@@ -564,7 +564,7 @@ namespace OpenSim.Region.UserStatistics
return uid;
}
- private void UpdateUserStats(UserSessionID uid, SqliteConnection db)
+ private void UpdateUserStats(UserSession uid, SqliteConnection db)
{
// m_log.DebugFormat(
// "[WEB STATS MODULE]: Updating user stats for {0} {1}, session {2}", uid.name_f, uid.name_l, uid.session_id);
@@ -999,7 +999,7 @@ VALUES
}
#region structs
- public class UserSessionID
+ public class UserSession
{
public UUID session_id;
public UUID region_id;
--
cgit v1.1