diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index faf746fac0..c11ea0225a 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -57,7 +57,12 @@ namespace OpenSim.Region.UserStatistics
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static SqliteConnection dbConn;
+
+ ///
+ /// User statistics sessions keyed by agent ID
+ ///
private Dictionary m_sessions = new Dictionary();
+
private List m_scenes = new List();
private Dictionary reports = new Dictionary();
private Dictionary m_simstatsCounters = new Dictionary();
@@ -308,49 +313,41 @@ namespace OpenSim.Region.UserStatistics
scene.EventManager.OnDeregisterCaps += OnDeRegisterCaps;
scene.EventManager.OnClientClosed += OnClientClosed;
scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
- scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
}
}
}
private void OnMakeRootAgent(ScenePresence agent)
{
- UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle);
-
lock (m_sessions)
{
+ UserSessionID uid;
+
if (!m_sessions.ContainsKey(agent.UUID))
{
UserSessionData usd = UserSessionUtil.newUserSessionData();
-
- UserSessionID uid = new UserSessionID();
+ uid = new UserSessionID();
uid.name_f = agent.Firstname;
uid.name_l = agent.Lastname;
- uid.region_id = regionUUID;
- uid.session_id = agent.ControllingClient.SessionId;
uid.session_data = usd;
m_sessions.Add(agent.UUID, uid);
}
else
{
- UserSessionID uid = m_sessions[agent.UUID];
- uid.region_id = regionUUID;
- uid.session_id = agent.ControllingClient.SessionId;
- m_sessions[agent.UUID] = uid;
+ uid = m_sessions[agent.UUID];
}
- }
- }
- private void OnMakeChildAgent(ScenePresence agent)
- {
+ uid.region_id = agent.Scene.RegionInfo.RegionID;
+ uid.session_id = agent.ControllingClient.SessionId;
+ }
}
private void OnClientClosed(UUID agentID, Scene scene)
{
lock (m_sessions)
{
- if (m_sessions.ContainsKey(agentID))
+ if (m_sessions.ContainsKey(agentID) && m_sessions[agentID].region_id == scene.RegionInfo.RegionID)
{
m_sessions.Remove(agentID);
}
@@ -395,20 +392,6 @@ namespace OpenSim.Region.UserStatistics
return encoding.GetString(buffer);
}
- private UUID GetRegionUUIDFromHandle(ulong regionhandle)
- {
- lock (m_scenes)
- {
- foreach (Scene scene in m_scenes)
- {
- if (scene.RegionInfo.RegionHandle == regionhandle)
- return scene.RegionInfo.RegionID;
- }
- }
-
- return UUID.Zero;
- }
-
///
/// Callback for a viewerstats cap
///