From ed14dac0a38defa64d36e691b12ba6a2e2b8642d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 16 Jul 2012 23:03:23 +0100 Subject: [PATCH 1/3] Stop warning about no session from ViewerStats if user teleports to another region in the same simulator that was not next to the source region. This was because teleporting to the new region invoked the new session setup code before the agent was removed from the old region, which then invoked the session teardown code. Now, we only invoke the teardown code if the region ID occupied by the agent being removed is the same as the one registered for the current session. --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index faf746fac0..d1a7217e4a 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,7 +313,6 @@ namespace OpenSim.Region.UserStatistics scene.EventManager.OnDeregisterCaps += OnDeRegisterCaps; scene.EventManager.OnClientClosed += OnClientClosed; scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; - scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; } } } @@ -342,15 +346,11 @@ namespace OpenSim.Region.UserStatistics } } - private void OnMakeChildAgent(ScenePresence agent) - { - } - 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); } From 217f47b0d5b2382a93f3947e0840056a3ba1abfd Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 16 Jul 2012 23:09:48 +0100 Subject: [PATCH 2/3] In WebStatsModule.OnMakeRootAgent(), get region ID directly from SP.Scene.RegionInfo.RegionID instead of manually looking it up from the stored scene list. --- .../Region/UserStatistics/WebStatsModule.cs | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index d1a7217e4a..ed424abadf 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -319,8 +319,6 @@ namespace OpenSim.Region.UserStatistics private void OnMakeRootAgent(ScenePresence agent) { - UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); - lock (m_sessions) { if (!m_sessions.ContainsKey(agent.UUID)) @@ -330,7 +328,7 @@ namespace OpenSim.Region.UserStatistics UserSessionID uid = new UserSessionID(); uid.name_f = agent.Firstname; uid.name_l = agent.Lastname; - uid.region_id = regionUUID; + uid.region_id = agent.Scene.RegionInfo.RegionID; uid.session_id = agent.ControllingClient.SessionId; uid.session_data = usd; @@ -339,7 +337,7 @@ namespace OpenSim.Region.UserStatistics else { UserSessionID uid = m_sessions[agent.UUID]; - uid.region_id = regionUUID; + uid.region_id = agent.Scene.RegionInfo.RegionID; uid.session_id = agent.ControllingClient.SessionId; m_sessions[agent.UUID] = uid; } @@ -395,20 +393,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 /// From c1667d39a610488e80e9d7c939ee7b449f02410d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 16 Jul 2012 23:15:02 +0100 Subject: [PATCH 3/3] refactor: factor out common code in WebStatsModule.OnMakeRootAgent() --- OpenSim/Region/UserStatistics/WebStatsModule.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index ed424abadf..c11ea0225a 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -321,26 +321,25 @@ namespace OpenSim.Region.UserStatistics { 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 = agent.Scene.RegionInfo.RegionID; - 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 = agent.Scene.RegionInfo.RegionID; - uid.session_id = agent.ControllingClient.SessionId; - m_sessions[agent.UUID] = uid; + uid = m_sessions[agent.UUID]; } + + uid.region_id = agent.Scene.RegionInfo.RegionID; + uid.session_id = agent.ControllingClient.SessionId; } }