aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorOren Hurvitz2014-04-20 12:47:30 +0300
committerOren Hurvitz2014-04-21 18:55:53 +0300
commitacc2c42a795b42df702ded3cc302daa8b3e4c04c (patch)
tree14e1dc2236151619ccf7bb72ce281b08bce2ac54
parentAdd 'lillith_xue' to list of CONTRIBUTORS.TXT (diff)
downloadopensim-SC_OLD-acc2c42a795b42df702ded3cc302daa8b3e4c04c.zip
opensim-SC_OLD-acc2c42a795b42df702ded3cc302daa8b3e4c04c.tar.gz
opensim-SC_OLD-acc2c42a795b42df702ded3cc302daa8b3e4c04c.tar.bz2
opensim-SC_OLD-acc2c42a795b42df702ded3cc302daa8b3e4c04c.tar.xz
Better logging in PresenceService, to help diagnose presence problems.
-rw-r--r--OpenSim/Data/MSSQL/Resources/Presence.migrations14
-rw-r--r--OpenSim/Data/MySQL/Resources/Presence.migrations10
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs88
3 files changed, 83 insertions, 29 deletions
diff --git a/OpenSim/Data/MSSQL/Resources/Presence.migrations b/OpenSim/Data/MSSQL/Resources/Presence.migrations
index bcb6328..f84275d 100644
--- a/OpenSim/Data/MSSQL/Resources/Presence.migrations
+++ b/OpenSim/Data/MSSQL/Resources/Presence.migrations
@@ -1,4 +1,4 @@
1:VERSION 1 1:VERSION 1
2 2
3BEGIN TRANSACTION 3BEGIN TRANSACTION
4 4
@@ -26,6 +26,14 @@ COMMIT
26 26
27BEGIN TRANSACTION 27BEGIN TRANSACTION
28 28
29ALTER TABLE Presence ADD LastSeen DateTime 29ALTER TABLE Presence ADD LastSeen DateTime;
30 30
31COMMIT \ No newline at end of file 31COMMIT
32
33:VERSION 3
34
35BEGIN TRANSACTION
36
37CREATE INDEX RegionID ON Presence(RegionID);
38
39COMMIT
diff --git a/OpenSim/Data/MySQL/Resources/Presence.migrations b/OpenSim/Data/MySQL/Resources/Presence.migrations
index be4030e..c4e40fa 100644
--- a/OpenSim/Data/MySQL/Resources/Presence.migrations
+++ b/OpenSim/Data/MySQL/Resources/Presence.migrations
@@ -1,4 +1,4 @@
1:VERSION 1 # -------------------------- 1:VERSION 1 # --------------------------
2 2
3BEGIN; 3BEGIN;
4 4
@@ -21,3 +21,11 @@ BEGIN;
21ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp; 21ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp;
22 22
23COMMIT; 23COMMIT;
24
25:VERSION 3 # --------------------------
26
27BEGIN;
28
29CREATE INDEX RegionID ON Presence(RegionID);
30
31COMMIT;
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index 7cd720c..0fe0200 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -41,9 +41,7 @@ namespace OpenSim.Services.PresenceService
41{ 41{
42 public class PresenceService : PresenceServiceBase, IPresenceService 42 public class PresenceService : PresenceServiceBase, IPresenceService
43 { 43 {
44 private static readonly ILog m_log = 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47 45
48 protected bool m_allowDuplicatePresences = false; 46 protected bool m_allowDuplicatePresences = false;
49 47
@@ -55,19 +53,15 @@ namespace OpenSim.Services.PresenceService
55 IConfig presenceConfig = config.Configs["PresenceService"]; 53 IConfig presenceConfig = config.Configs["PresenceService"];
56 if (presenceConfig != null) 54 if (presenceConfig != null)
57 { 55 {
58 m_allowDuplicatePresences = 56 m_allowDuplicatePresences = presenceConfig.GetBoolean("AllowDuplicatePresences", m_allowDuplicatePresences);
59 presenceConfig.GetBoolean("AllowDuplicatePresences",
60 m_allowDuplicatePresences);
61 } 57 }
62 } 58 }
63 59
64 public bool LoginAgent(string userID, UUID sessionID, 60 public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID)
65 UUID secureSessionID)
66 { 61 {
67 //PresenceData[] d = m_Database.Get("UserID", userID); 62 PresenceData prevUser = GetUser(userID);
68 //m_Database.Get("UserID", userID);
69 63
70 if (!m_allowDuplicatePresences) 64 if (!m_allowDuplicatePresences && (prevUser != null))
71 m_Database.Delete("UserID", userID.ToString()); 65 m_Database.Delete("UserID", userID.ToString());
72 66
73 PresenceData data = new PresenceData(); 67 PresenceData data = new PresenceData();
@@ -80,20 +74,41 @@ namespace OpenSim.Services.PresenceService
80 74
81 m_Database.Store(data); 75 m_Database.Store(data);
82 76
83 m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent {0} with session {1} and secure session {2}", 77 string prevUserStr = "";
84 userID, sessionID, secureSessionID); 78 if (prevUser != null)
79 prevUserStr = string.Format(". This user was already logged-in: session {0}, region {1}", prevUser.SessionID, prevUser.RegionID);
80
81 m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent: session {0}, user {1}, region {2}, secure session {3}{4}",
82 data.SessionID, data.UserID, data.RegionID, secureSessionID, prevUserStr);
83
85 return true; 84 return true;
86 } 85 }
87 86
88 public bool LogoutAgent(UUID sessionID) 87 public bool LogoutAgent(UUID sessionID)
89 { 88 {
90 m_log.DebugFormat("[PRESENCE SERVICE]: Session {0} logout", sessionID); 89 PresenceInfo presence = GetAgent(sessionID);
90
91 m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent: session {0}, user {1}, region {2}",
92 sessionID,
93 (presence == null) ? null : presence.UserID,
94 (presence == null) ? null : presence.RegionID.ToString());
95
91 return m_Database.Delete("SessionID", sessionID.ToString()); 96 return m_Database.Delete("SessionID", sessionID.ToString());
92 } 97 }
93 98
94 public bool LogoutRegionAgents(UUID regionID) 99 public bool LogoutRegionAgents(UUID regionID)
95 { 100 {
96 m_log.DebugFormat("[PRESENCE SERVICE]: Logout agents in region {0}", regionID); 101 PresenceData[] prevSessions = GetRegionAgents(regionID);
102
103 if ((prevSessions == null) || (prevSessions.Length == 0))
104 return true;
105
106 m_log.DebugFormat("[PRESENCE SERVICE]: Logout users in region {0}: {1}", regionID,
107 string.Join(", ", Array.ConvertAll(prevSessions, session => session.UserID)));
108
109 // There's a small chance that LogoutRegionAgents() will logout different users than the
110 // list that was logged above, but it's unlikely and not worth dealing with.
111
97 m_Database.LogoutRegionAgents(regionID); 112 m_Database.LogoutRegionAgents(regionID);
98 113
99 return true; 114 return true;
@@ -102,20 +117,26 @@ namespace OpenSim.Services.PresenceService
102 117
103 public bool ReportAgent(UUID sessionID, UUID regionID) 118 public bool ReportAgent(UUID sessionID, UUID regionID)
104 { 119 {
105// m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID);
106 try 120 try
107 { 121 {
108 PresenceData pdata = m_Database.Get(sessionID); 122 PresenceData presence = m_Database.Get(sessionID);
109 if (pdata == null) 123
110 return false; 124 bool success;
111 if (pdata.Data == null) 125 if (presence == null)
112 return false; 126 success = false;
127 else
128 success = m_Database.ReportAgent(sessionID, regionID);
113 129
114 return m_Database.ReportAgent(sessionID, regionID); 130 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent{0}: session {1}, user {2}, region {3}. Previously: {4}",
131 success ? "" : " failed",
132 sessionID, (presence == null) ? null : presence.UserID, regionID,
133 (presence == null) ? "not logged-in" : "region " + presence.RegionID);
134
135 return success;
115 } 136 }
116 catch (Exception e) 137 catch (Exception e)
117 { 138 {
118 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent threw exception {0}", e.StackTrace); 139 m_log.Debug(string.Format("[PRESENCE SERVICE]: ReportAgent for session {0} threw exception ", sessionID), e);
119 return false; 140 return false;
120 } 141 }
121 } 142 }
@@ -140,8 +161,7 @@ namespace OpenSim.Services.PresenceService
140 161
141 foreach (string userIDStr in userIDs) 162 foreach (string userIDStr in userIDs)
142 { 163 {
143 PresenceData[] data = m_Database.Get("UserID", 164 PresenceData[] data = m_Database.Get("UserID", userIDStr);
144 userIDStr);
145 165
146 foreach (PresenceData d in data) 166 foreach (PresenceData d in data)
147 { 167 {
@@ -159,5 +179,23 @@ namespace OpenSim.Services.PresenceService
159 179
160 return info.ToArray(); 180 return info.ToArray();
161 } 181 }
182
183 /// <summary>
184 /// Return the user's Presence. This only really works well if !AllowDuplicatePresences, but that's the default.
185 /// </summary>
186 private PresenceData GetUser(string userID)
187 {
188 PresenceData[] data = m_Database.Get("UserID", userID);
189 if (data.Length > 0)
190 return data[0];
191 else
192 return null;
193 }
194
195 private PresenceData[] GetRegionAgents(UUID regionID)
196 {
197 return m_Database.Get("RegionID", regionID.ToString());
198 }
199
162 } 200 }
163} \ No newline at end of file 201} \ No newline at end of file