diff options
author | Melanie Thielker | 2017-03-31 14:50:14 +0100 |
---|---|---|
committer | Melanie Thielker | 2017-03-31 14:50:14 +0100 |
commit | 5587ee45005bd99ee01cefd8fb3ae3f2b91bf284 (patch) | |
tree | 2863324dc4f7832d60c22118268b8a432fb7c1bf /OpenSim | |
parent | add CanSellObject() permitions check functions (diff) | |
parent | If a DNS resolution fails on an outbound request, simply allow it (diff) | |
download | opensim-SC_OLD-5587ee45005bd99ee01cefd8fb3ae3f2b91bf284.zip opensim-SC_OLD-5587ee45005bd99ee01cefd8fb3ae3f2b91bf284.tar.gz opensim-SC_OLD-5587ee45005bd99ee01cefd8fb3ae3f2b91bf284.tar.bz2 opensim-SC_OLD-5587ee45005bd99ee01cefd8fb3ae3f2b91bf284.tar.xz |
Merge branch 'melanie'
Diffstat (limited to 'OpenSim')
15 files changed, 614 insertions, 95 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 597b439..1ee2468 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -359,6 +359,42 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
359 | notice = false; | 359 | notice = false; |
360 | } | 360 | } |
361 | 361 | ||
362 | if (startupConfig.GetBoolean("SkipDelayOnEmptyRegion", false)) | ||
363 | { | ||
364 | m_log.Info("[RADMIN]: Counting affected avatars"); | ||
365 | int agents = 0; | ||
366 | |||
367 | if (restartAll) | ||
368 | { | ||
369 | foreach (Scene s in m_application.SceneManager.Scenes) | ||
370 | { | ||
371 | foreach (ScenePresence sp in s.GetScenePresences()) | ||
372 | { | ||
373 | if (!sp.IsChildAgent && !sp.IsNPC) | ||
374 | agents++; | ||
375 | } | ||
376 | } | ||
377 | } | ||
378 | else | ||
379 | { | ||
380 | foreach (ScenePresence sp in rebootedScene.GetScenePresences()) | ||
381 | { | ||
382 | if (!sp.IsChildAgent && !sp.IsNPC) | ||
383 | agents++; | ||
384 | } | ||
385 | } | ||
386 | |||
387 | m_log.InfoFormat("[RADMIN]: Avatars in region: {0}", agents); | ||
388 | |||
389 | if (agents == 0) | ||
390 | { | ||
391 | m_log.Info("[RADMIN]: No avatars detected, shutting down without delay"); | ||
392 | |||
393 | times.Clear(); | ||
394 | times.Add(0); | ||
395 | } | ||
396 | } | ||
397 | |||
362 | List<Scene> restartList; | 398 | List<Scene> restartList; |
363 | 399 | ||
364 | if (restartAll) | 400 | if (restartAll) |
@@ -376,10 +412,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
376 | } | 412 | } |
377 | catch (Exception e) | 413 | catch (Exception e) |
378 | { | 414 | { |
379 | // m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0} {1}", e.Message, e.StackTrace); | 415 | m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0} {1}", e.Message, e.StackTrace); |
380 | responseData["rebooting"] = false; | 416 | responseData["rebooting"] = false; |
381 | 417 | ||
382 | throw e; | 418 | throw; |
383 | } | 419 | } |
384 | 420 | ||
385 | m_log.Info("[RADMIN]: Restart Region request complete"); | 421 | m_log.Info("[RADMIN]: Restart Region request complete"); |
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index 34791cf..93662db 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -36,7 +36,7 @@ using MySql.Data.MySqlClient; | |||
36 | namespace OpenSim.Data.MySQL | 36 | namespace OpenSim.Data.MySQL |
37 | { | 37 | { |
38 | /// <summary> | 38 | /// <summary> |
39 | /// A database interface class to a user profile storage system | 39 | /// Common code for a number of database modules |
40 | /// </summary> | 40 | /// </summary> |
41 | public class MySqlFramework | 41 | public class MySqlFramework |
42 | { | 42 | { |
@@ -44,14 +44,24 @@ namespace OpenSim.Data.MySQL | |||
44 | log4net.LogManager.GetLogger( | 44 | log4net.LogManager.GetLogger( |
45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 45 | System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | protected string m_connectionString; | 47 | protected string m_connectionString = String.Empty; |
48 | protected object m_dbLock = new object(); | 48 | protected MySqlTransaction m_trans = null; |
49 | 49 | ||
50 | // Constructor using a connection string. Instances constructed | ||
51 | // this way will open a new connection for each call. | ||
50 | protected MySqlFramework(string connectionString) | 52 | protected MySqlFramework(string connectionString) |
51 | { | 53 | { |
52 | m_connectionString = connectionString; | 54 | m_connectionString = connectionString; |
53 | } | 55 | } |
54 | 56 | ||
57 | // Constructor using a connection object. Instances constructed | ||
58 | // this way will use the connection object and never create | ||
59 | // new connections. | ||
60 | protected MySqlFramework(MySqlTransaction trans) | ||
61 | { | ||
62 | m_trans = trans; | ||
63 | } | ||
64 | |||
55 | ////////////////////////////////////////////////////////////// | 65 | ////////////////////////////////////////////////////////////// |
56 | // | 66 | // |
57 | // All non queries are funneled through one connection | 67 | // All non queries are funneled through one connection |
@@ -59,33 +69,48 @@ namespace OpenSim.Data.MySQL | |||
59 | // | 69 | // |
60 | protected int ExecuteNonQuery(MySqlCommand cmd) | 70 | protected int ExecuteNonQuery(MySqlCommand cmd) |
61 | { | 71 | { |
62 | lock (m_dbLock) | 72 | if (m_trans == null) |
63 | { | 73 | { |
64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 74 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
65 | { | 75 | { |
66 | try | 76 | dbcon.Open(); |
67 | { | 77 | return ExecuteNonQueryWithConnection(cmd, dbcon); |
68 | dbcon.Open(); | 78 | } |
69 | cmd.Connection = dbcon; | 79 | } |
80 | else | ||
81 | { | ||
82 | return ExecuteNonQueryWithTransaction(cmd, m_trans); | ||
83 | } | ||
84 | } | ||
70 | 85 | ||
71 | try | 86 | private int ExecuteNonQueryWithTransaction(MySqlCommand cmd, MySqlTransaction trans) |
72 | { | 87 | { |
73 | return cmd.ExecuteNonQuery(); | 88 | cmd.Transaction = trans; |
74 | } | 89 | return ExecuteNonQueryWithConnection(cmd, trans.Connection); |
75 | catch (Exception e) | 90 | } |
76 | { | 91 | |
77 | m_log.Error(e.Message, e); | 92 | private int ExecuteNonQueryWithConnection(MySqlCommand cmd, MySqlConnection dbcon) |
78 | m_log.Error(Environment.StackTrace.ToString()); | 93 | { |
79 | return 0; | 94 | try |
80 | } | 95 | { |
81 | } | 96 | cmd.Connection = dbcon; |
82 | catch (Exception e) | 97 | |
83 | { | 98 | try |
84 | m_log.Error(e.Message, e); | 99 | { |
85 | return 0; | 100 | return cmd.ExecuteNonQuery(); |
86 | } | ||
87 | } | 101 | } |
102 | catch (Exception e) | ||
103 | { | ||
104 | m_log.Error(e.Message, e); | ||
105 | m_log.Error(Environment.StackTrace.ToString()); | ||
106 | return 0; | ||
107 | } | ||
108 | } | ||
109 | catch (Exception e) | ||
110 | { | ||
111 | m_log.Error(e.Message, e); | ||
112 | return 0; | ||
88 | } | 113 | } |
89 | } | 114 | } |
90 | } | 115 | } |
91 | } \ No newline at end of file | 116 | } |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 6aae9c6..bd8bbd5 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -53,14 +53,27 @@ namespace OpenSim.Data.MySQL | |||
53 | get { return GetType().Assembly; } | 53 | get { return GetType().Assembly; } |
54 | } | 54 | } |
55 | 55 | ||
56 | public MySQLGenericTableHandler(MySqlTransaction trans, | ||
57 | string realm, string storeName) : base(trans) | ||
58 | { | ||
59 | m_Realm = realm; | ||
60 | |||
61 | CommonConstruct(storeName); | ||
62 | } | ||
63 | |||
56 | public MySQLGenericTableHandler(string connectionString, | 64 | public MySQLGenericTableHandler(string connectionString, |
57 | string realm, string storeName) : base(connectionString) | 65 | string realm, string storeName) : base(connectionString) |
58 | { | 66 | { |
59 | m_Realm = realm; | 67 | m_Realm = realm; |
60 | m_connectionString = connectionString; | ||
61 | 68 | ||
69 | CommonConstruct(storeName); | ||
70 | } | ||
71 | |||
72 | protected void CommonConstruct(string storeName) | ||
73 | { | ||
62 | if (storeName != String.Empty) | 74 | if (storeName != String.Empty) |
63 | { | 75 | { |
76 | // We always use a new connection for any Migrations | ||
64 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 77 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
65 | { | 78 | { |
66 | dbcon.Open(); | 79 | dbcon.Open(); |
@@ -111,6 +124,11 @@ namespace OpenSim.Data.MySQL | |||
111 | 124 | ||
112 | public virtual T[] Get(string[] fields, string[] keys) | 125 | public virtual T[] Get(string[] fields, string[] keys) |
113 | { | 126 | { |
127 | return Get(fields, keys, String.Empty); | ||
128 | } | ||
129 | |||
130 | public virtual T[] Get(string[] fields, string[] keys, string options) | ||
131 | { | ||
114 | if (fields.Length != keys.Length) | 132 | if (fields.Length != keys.Length) |
115 | return new T[0]; | 133 | return new T[0]; |
116 | 134 | ||
@@ -126,8 +144,8 @@ namespace OpenSim.Data.MySQL | |||
126 | 144 | ||
127 | string where = String.Join(" and ", terms.ToArray()); | 145 | string where = String.Join(" and ", terms.ToArray()); |
128 | 146 | ||
129 | string query = String.Format("select * from {0} where {1}", | 147 | string query = String.Format("select * from {0} where {1} {2}", |
130 | m_Realm, where); | 148 | m_Realm, where, options); |
131 | 149 | ||
132 | cmd.CommandText = query; | 150 | cmd.CommandText = query; |
133 | 151 | ||
@@ -137,72 +155,92 @@ namespace OpenSim.Data.MySQL | |||
137 | 155 | ||
138 | protected T[] DoQuery(MySqlCommand cmd) | 156 | protected T[] DoQuery(MySqlCommand cmd) |
139 | { | 157 | { |
158 | if (m_trans == null) | ||
159 | { | ||
160 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
161 | { | ||
162 | dbcon.Open(); | ||
163 | |||
164 | return DoQueryWithConnection(cmd, dbcon); | ||
165 | } | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | return DoQueryWithTransaction(cmd, m_trans); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | protected T[] DoQueryWithTransaction(MySqlCommand cmd, MySqlTransaction trans) | ||
174 | { | ||
175 | cmd.Transaction = trans; | ||
176 | |||
177 | return DoQueryWithConnection(cmd, trans.Connection); | ||
178 | } | ||
179 | |||
180 | protected T[] DoQueryWithConnection(MySqlCommand cmd, MySqlConnection dbcon) | ||
181 | { | ||
140 | List<T> result = new List<T>(); | 182 | List<T> result = new List<T>(); |
141 | 183 | ||
142 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 184 | cmd.Connection = dbcon; |
185 | |||
186 | using (IDataReader reader = cmd.ExecuteReader()) | ||
143 | { | 187 | { |
144 | dbcon.Open(); | 188 | if (reader == null) |
145 | cmd.Connection = dbcon; | 189 | return new T[0]; |
146 | 190 | ||
147 | using (IDataReader reader = cmd.ExecuteReader()) | 191 | CheckColumnNames(reader); |
148 | { | ||
149 | if (reader == null) | ||
150 | return new T[0]; | ||
151 | 192 | ||
152 | CheckColumnNames(reader); | 193 | while (reader.Read()) |
194 | { | ||
195 | T row = new T(); | ||
153 | 196 | ||
154 | while (reader.Read()) | 197 | foreach (string name in m_Fields.Keys) |
155 | { | 198 | { |
156 | T row = new T(); | 199 | if (reader[name] is DBNull) |
157 | |||
158 | foreach (string name in m_Fields.Keys) | ||
159 | { | 200 | { |
160 | if (reader[name] is DBNull) | 201 | continue; |
161 | { | ||
162 | continue; | ||
163 | } | ||
164 | if (m_Fields[name].FieldType == typeof(bool)) | ||
165 | { | ||
166 | int v = Convert.ToInt32(reader[name]); | ||
167 | m_Fields[name].SetValue(row, v != 0 ? true : false); | ||
168 | } | ||
169 | else if (m_Fields[name].FieldType == typeof(UUID)) | ||
170 | { | ||
171 | m_Fields[name].SetValue(row, DBGuid.FromDB(reader[name])); | ||
172 | } | ||
173 | else if (m_Fields[name].FieldType == typeof(int)) | ||
174 | { | ||
175 | int v = Convert.ToInt32(reader[name]); | ||
176 | m_Fields[name].SetValue(row, v); | ||
177 | } | ||
178 | else if (m_Fields[name].FieldType == typeof(uint)) | ||
179 | { | ||
180 | uint v = Convert.ToUInt32(reader[name]); | ||
181 | m_Fields[name].SetValue(row, v); | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | m_Fields[name].SetValue(row, reader[name]); | ||
186 | } | ||
187 | } | 202 | } |
188 | 203 | if (m_Fields[name].FieldType == typeof(bool)) | |
189 | if (m_DataField != null) | 204 | { |
205 | int v = Convert.ToInt32(reader[name]); | ||
206 | m_Fields[name].SetValue(row, v != 0 ? true : false); | ||
207 | } | ||
208 | else if (m_Fields[name].FieldType == typeof(UUID)) | ||
209 | { | ||
210 | m_Fields[name].SetValue(row, DBGuid.FromDB(reader[name])); | ||
211 | } | ||
212 | else if (m_Fields[name].FieldType == typeof(int)) | ||
213 | { | ||
214 | int v = Convert.ToInt32(reader[name]); | ||
215 | m_Fields[name].SetValue(row, v); | ||
216 | } | ||
217 | else if (m_Fields[name].FieldType == typeof(uint)) | ||
218 | { | ||
219 | uint v = Convert.ToUInt32(reader[name]); | ||
220 | m_Fields[name].SetValue(row, v); | ||
221 | } | ||
222 | else | ||
190 | { | 223 | { |
191 | Dictionary<string, string> data = | 224 | m_Fields[name].SetValue(row, reader[name]); |
192 | new Dictionary<string, string>(); | 225 | } |
226 | } | ||
193 | 227 | ||
194 | foreach (string col in m_ColumnNames) | 228 | if (m_DataField != null) |
195 | { | 229 | { |
196 | data[col] = reader[col].ToString(); | 230 | Dictionary<string, string> data = |
197 | if (data[col] == null) | 231 | new Dictionary<string, string>(); |
198 | data[col] = String.Empty; | ||
199 | } | ||
200 | 232 | ||
201 | m_DataField.SetValue(row, data); | 233 | foreach (string col in m_ColumnNames) |
234 | { | ||
235 | data[col] = reader[col].ToString(); | ||
236 | if (data[col] == null) | ||
237 | data[col] = String.Empty; | ||
202 | } | 238 | } |
203 | 239 | ||
204 | result.Add(row); | 240 | m_DataField.SetValue(row, data); |
205 | } | 241 | } |
242 | |||
243 | result.Add(row); | ||
206 | } | 244 | } |
207 | } | 245 | } |
208 | 246 | ||
@@ -357,14 +395,23 @@ namespace OpenSim.Data.MySQL | |||
357 | 395 | ||
358 | public object DoQueryScalar(MySqlCommand cmd) | 396 | public object DoQueryScalar(MySqlCommand cmd) |
359 | { | 397 | { |
360 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 398 | if (m_trans == null) |
361 | { | 399 | { |
362 | dbcon.Open(); | 400 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
363 | cmd.Connection = dbcon; | 401 | { |
402 | dbcon.Open(); | ||
403 | cmd.Connection = dbcon; | ||
404 | |||
405 | return cmd.ExecuteScalar(); | ||
406 | } | ||
407 | } | ||
408 | else | ||
409 | { | ||
410 | cmd.Connection = m_trans.Connection; | ||
411 | cmd.Transaction = m_trans; | ||
364 | 412 | ||
365 | return cmd.ExecuteScalar(); | 413 | return cmd.ExecuteScalar(); |
366 | } | 414 | } |
367 | } | 415 | } |
368 | |||
369 | } | 416 | } |
370 | } | 417 | } |
diff --git a/OpenSim/Framework/OutboundUrlFilter.cs b/OpenSim/Framework/OutboundUrlFilter.cs index ee4707f..63ae361 100644 --- a/OpenSim/Framework/OutboundUrlFilter.cs +++ b/OpenSim/Framework/OutboundUrlFilter.cs | |||
@@ -212,7 +212,17 @@ namespace OpenSim.Framework | |||
212 | // Check that we are permitted to make calls to this endpoint. | 212 | // Check that we are permitted to make calls to this endpoint. |
213 | bool foundIpv4Address = false; | 213 | bool foundIpv4Address = false; |
214 | 214 | ||
215 | IPAddress[] addresses = Dns.GetHostAddresses(url.Host); | 215 | IPAddress[] addresses = null; |
216 | |||
217 | try | ||
218 | { | ||
219 | addresses = Dns.GetHostAddresses(url.Host); | ||
220 | } | ||
221 | catch | ||
222 | { | ||
223 | // If there is a DNS error, we can't stop the script! | ||
224 | return true; | ||
225 | } | ||
216 | 226 | ||
217 | foreach (IPAddress addr in addresses) | 227 | foreach (IPAddress addr in addresses) |
218 | { | 228 | { |
@@ -253,4 +263,4 @@ namespace OpenSim.Framework | |||
253 | return allowed; | 263 | return allowed; |
254 | } | 264 | } |
255 | } | 265 | } |
256 | } \ No newline at end of file | 266 | } |
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs index 8965e71..f627ae6 100644 --- a/OpenSim/Framework/Servers/ServerBase.cs +++ b/OpenSim/Framework/Servers/ServerBase.cs | |||
@@ -57,6 +57,7 @@ namespace OpenSim.Framework.Servers | |||
57 | 57 | ||
58 | protected OpenSimAppender m_consoleAppender; | 58 | protected OpenSimAppender m_consoleAppender; |
59 | protected FileAppender m_logFileAppender; | 59 | protected FileAppender m_logFileAppender; |
60 | protected FileAppender m_statsLogFileAppender; | ||
60 | 61 | ||
61 | protected DateTime m_startuptime; | 62 | protected DateTime m_startuptime; |
62 | protected string m_startupDirectory = Environment.CurrentDirectory; | 63 | protected string m_startupDirectory = Environment.CurrentDirectory; |
@@ -156,6 +157,10 @@ namespace OpenSim.Framework.Servers | |||
156 | { | 157 | { |
157 | m_logFileAppender = (FileAppender)appender; | 158 | m_logFileAppender = (FileAppender)appender; |
158 | } | 159 | } |
160 | else if (appender.Name == "StatsLogFileAppender") | ||
161 | { | ||
162 | m_statsLogFileAppender = (FileAppender)appender; | ||
163 | } | ||
159 | } | 164 | } |
160 | 165 | ||
161 | if (null == m_consoleAppender) | 166 | if (null == m_consoleAppender) |
@@ -185,6 +190,18 @@ namespace OpenSim.Framework.Servers | |||
185 | 190 | ||
186 | m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File); | 191 | m_log.InfoFormat("[SERVER BASE]: Logging started to file {0}", m_logFileAppender.File); |
187 | } | 192 | } |
193 | |||
194 | if (m_statsLogFileAppender != null && startupConfig != null) | ||
195 | { | ||
196 | string cfgStatsFileName = startupConfig.GetString("StatsLogFile", null); | ||
197 | if (cfgStatsFileName != null) | ||
198 | { | ||
199 | m_statsLogFileAppender.File = cfgStatsFileName; | ||
200 | m_statsLogFileAppender.ActivateOptions(); | ||
201 | } | ||
202 | |||
203 | m_log.InfoFormat("[SERVER BASE]: Stats Logging started to file {0}", m_statsLogFileAppender.File); | ||
204 | } | ||
188 | } | 205 | } |
189 | 206 | ||
190 | /// <summary> | 207 | /// <summary> |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 9f5868b..0ec24e6 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1192,7 +1192,7 @@ namespace OpenSim.Framework | |||
1192 | { | 1192 | { |
1193 | foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) | 1193 | foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) |
1194 | { | 1194 | { |
1195 | if (appender is FileAppender) | 1195 | if (appender is FileAppender && appender.Name == "LogFileAppender") |
1196 | { | 1196 | { |
1197 | return ((FileAppender)appender).File; | 1197 | return ((FileAppender)appender).File; |
1198 | } | 1198 | } |
@@ -1201,6 +1201,19 @@ namespace OpenSim.Framework | |||
1201 | return "./OpenSim.log"; | 1201 | return "./OpenSim.log"; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | public static string statsLogFile() | ||
1205 | { | ||
1206 | foreach (IAppender appender in LogManager.GetRepository().GetAppenders()) | ||
1207 | { | ||
1208 | if (appender is FileAppender && appender.Name == "StatsLogFileAppender") | ||
1209 | { | ||
1210 | return ((FileAppender)appender).File; | ||
1211 | } | ||
1212 | } | ||
1213 | |||
1214 | return "./OpenSimStats.log"; | ||
1215 | } | ||
1216 | |||
1204 | public static string logDir() | 1217 | public static string logDir() |
1205 | { | 1218 | { |
1206 | return Path.GetDirectoryName(logFile()); | 1219 | return Path.GetDirectoryName(logFile()); |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index f8a4461..610e279 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -806,6 +806,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
806 | 806 | ||
807 | return; | 807 | return; |
808 | } | 808 | } |
809 | catch (UnauthorizedAccessException e) | ||
810 | { | ||
811 | } | ||
809 | finally | 812 | finally |
810 | { | 813 | { |
811 | if (stream != null) | 814 | if (stream != null) |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 51f973a..32cb5a3 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -957,9 +957,14 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
957 | 957 | ||
958 | public virtual bool IsLocalGridUser(UUID uuid) | 958 | public virtual bool IsLocalGridUser(UUID uuid) |
959 | { | 959 | { |
960 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); | 960 | lock (m_Scenes) |
961 | if (account == null || (account != null && !account.LocalToGrid)) | 961 | { |
962 | return false; | 962 | if (m_Scenes.Count == 0) |
963 | return true; | ||
964 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); | ||
965 | if (account == null || (account != null && !account.LocalToGrid)) | ||
966 | return false; | ||
967 | } | ||
963 | 968 | ||
964 | return true; | 969 | return true; |
965 | } | 970 | } |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 7f2b29a..bc86076 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -2032,6 +2032,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
2032 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 2032 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
2033 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 2033 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
2034 | 2034 | ||
2035 | // A god is a god is a god | ||
2036 | if (IsAdministrator(user)) | ||
2037 | return true; | ||
2038 | |||
2035 | if (objectID == UUID.Zero) // User inventory | 2039 | if (objectID == UUID.Zero) // User inventory |
2036 | { | 2040 | { |
2037 | IInventoryService invService = m_scene.InventoryService; | 2041 | IInventoryService invService = m_scene.InventoryService; |
@@ -2121,6 +2125,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
2121 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | 2125 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); |
2122 | if (m_bypassPermissions) return m_bypassPermissionsValue; | 2126 | if (m_bypassPermissions) return m_bypassPermissionsValue; |
2123 | 2127 | ||
2128 | // A god is a god is a god | ||
2129 | if (IsAdministrator(user)) | ||
2130 | return true; | ||
2131 | |||
2124 | if (objectID == UUID.Zero) // User inventory | 2132 | if (objectID == UUID.Zero) // User inventory |
2125 | { | 2133 | { |
2126 | IInventoryService invService = m_scene.InventoryService; | 2134 | IInventoryService invService = m_scene.InventoryService; |
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index 8bac9e6..bb3b860 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs | |||
@@ -61,6 +61,8 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
61 | protected IDialogModule m_DialogModule = null; | 61 | protected IDialogModule m_DialogModule = null; |
62 | protected string m_MarkerPath = String.Empty; | 62 | protected string m_MarkerPath = String.Empty; |
63 | private int[] m_CurrentAlerts = null; | 63 | private int[] m_CurrentAlerts = null; |
64 | protected bool m_shortCircuitDelays = false; | ||
65 | protected bool m_rebootAll = false; | ||
64 | 66 | ||
65 | public void Initialise(IConfigSource config) | 67 | public void Initialise(IConfigSource config) |
66 | { | 68 | { |
@@ -69,6 +71,9 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
69 | { | 71 | { |
70 | m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty); | 72 | m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty); |
71 | } | 73 | } |
74 | IConfig startupConfig = config.Configs["Startup"]; | ||
75 | m_shortCircuitDelays = startupConfig.GetBoolean("SkipDelayOnEmptyRegion", false); | ||
76 | m_rebootAll = startupConfig.GetBoolean("InworldRestartShutsDown", false); | ||
72 | } | 77 | } |
73 | 78 | ||
74 | public void AddRegion(Scene scene) | 79 | public void AddRegion(Scene scene) |
@@ -250,6 +255,14 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
250 | private void OnTimer(object source, ElapsedEventArgs e) | 255 | private void OnTimer(object source, ElapsedEventArgs e) |
251 | { | 256 | { |
252 | int nextInterval = DoOneNotice(true); | 257 | int nextInterval = DoOneNotice(true); |
258 | if (m_shortCircuitDelays) | ||
259 | { | ||
260 | if (CountAgents() == 0) | ||
261 | { | ||
262 | m_Scene.RestartNow(); | ||
263 | return; | ||
264 | } | ||
265 | } | ||
253 | 266 | ||
254 | SetTimer(nextInterval); | 267 | SetTimer(nextInterval); |
255 | } | 268 | } |
@@ -349,5 +362,35 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
349 | { | 362 | { |
350 | } | 363 | } |
351 | } | 364 | } |
365 | |||
366 | int CountAgents() | ||
367 | { | ||
368 | m_log.Info("[RESTART MODULE]: Counting affected avatars"); | ||
369 | int agents = 0; | ||
370 | |||
371 | if (m_rebootAll) | ||
372 | { | ||
373 | foreach (Scene s in SceneManager.Instance.Scenes) | ||
374 | { | ||
375 | foreach (ScenePresence sp in s.GetScenePresences()) | ||
376 | { | ||
377 | if (!sp.IsChildAgent && !sp.IsNPC) | ||
378 | agents++; | ||
379 | } | ||
380 | } | ||
381 | } | ||
382 | else | ||
383 | { | ||
384 | foreach (ScenePresence sp in m_Scene.GetScenePresences()) | ||
385 | { | ||
386 | if (!sp.IsChildAgent && !sp.IsNPC) | ||
387 | agents++; | ||
388 | } | ||
389 | } | ||
390 | |||
391 | m_log.InfoFormat("[RESTART MODULE]: Avatars in region: {0}", agents); | ||
392 | |||
393 | return agents; | ||
394 | } | ||
352 | } | 395 | } |
353 | } | 396 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IEtcdModule.cs b/OpenSim/Region/Framework/Interfaces/IEtcdModule.cs new file mode 100644 index 0000000..123cb67 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IEtcdModule.cs | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | |||
30 | public interface IEtcdModule | ||
31 | { | ||
32 | bool Store(string k, string v); | ||
33 | bool Store(string k, string v, int ttl); | ||
34 | string Get(string k); | ||
35 | void Watch(string k, Action<string> callback); | ||
36 | void Delete(string k); | ||
37 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5f99b73..c5b082c 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -540,6 +540,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
540 | private Timer m_mapGenerationTimer = new Timer(); | 540 | private Timer m_mapGenerationTimer = new Timer(); |
541 | private bool m_generateMaptiles; | 541 | private bool m_generateMaptiles; |
542 | 542 | ||
543 | protected int m_lastHealth = -1; | ||
544 | protected int m_lastUsers = -1; | ||
545 | |||
543 | #endregion Fields | 546 | #endregion Fields |
544 | 547 | ||
545 | #region Properties | 548 | #region Properties |
@@ -1212,6 +1215,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1212 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1215 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1213 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1216 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1214 | 1217 | ||
1218 | IConfig restartConfig = config.Configs["RestartModule"]; | ||
1219 | if (restartConfig != null) | ||
1220 | { | ||
1221 | string markerPath = restartConfig.GetString("MarkerPath", String.Empty); | ||
1222 | |||
1223 | if (markerPath != String.Empty) | ||
1224 | { | ||
1225 | string path = Path.Combine(markerPath, RegionInfo.RegionID.ToString() + ".started"); | ||
1226 | try | ||
1227 | { | ||
1228 | string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); | ||
1229 | FileStream fs = File.Create(path); | ||
1230 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
1231 | Byte[] buf = enc.GetBytes(pidstring); | ||
1232 | fs.Write(buf, 0, buf.Length); | ||
1233 | fs.Close(); | ||
1234 | } | ||
1235 | catch (Exception) | ||
1236 | { | ||
1237 | } | ||
1238 | } | ||
1239 | } | ||
1240 | |||
1241 | StartTimerWatchdog(); | ||
1215 | } | 1242 | } |
1216 | 1243 | ||
1217 | public Scene(RegionInfo regInfo) | 1244 | public Scene(RegionInfo regInfo) |
@@ -1482,6 +1509,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1482 | return; | 1509 | return; |
1483 | } | 1510 | } |
1484 | 1511 | ||
1512 | IEtcdModule etcd = RequestModuleInterface<IEtcdModule>(); | ||
1513 | if (etcd != null) | ||
1514 | { | ||
1515 | etcd.Delete("Health"); | ||
1516 | etcd.Delete("HealthFlags"); | ||
1517 | etcd.Delete("RootAgents"); | ||
1518 | } | ||
1519 | |||
1485 | m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); | 1520 | m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); |
1486 | 1521 | ||
1487 | 1522 | ||
@@ -1520,6 +1555,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1520 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1555 | m_log.Debug("[SCENE]: Persisting changed objects"); |
1521 | Backup(true); | 1556 | Backup(true); |
1522 | 1557 | ||
1558 | m_log.Debug("[SCENE]: Closing scene"); | ||
1559 | |||
1523 | m_sceneGraph.Close(); | 1560 | m_sceneGraph.Close(); |
1524 | 1561 | ||
1525 | base.Close(); | 1562 | base.Close(); |
@@ -3989,7 +4026,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3989 | 4026 | ||
3990 | if (!LoginsEnabled) | 4027 | if (!LoginsEnabled) |
3991 | { | 4028 | { |
3992 | reason = "Logins Disabled"; | 4029 | reason = "Logins to this region are disabled"; |
3993 | return false; | 4030 | return false; |
3994 | } | 4031 | } |
3995 | 4032 | ||
@@ -5512,23 +5549,24 @@ Label_GroupsDone: | |||
5512 | return 0; | 5549 | return 0; |
5513 | } | 5550 | } |
5514 | 5551 | ||
5515 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5552 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 2000) |
5516 | { | 5553 | { |
5517 | health+=1; | 5554 | health+=1; |
5518 | flags |= 1; | 5555 | flags |= 1; |
5519 | } | 5556 | } |
5520 | 5557 | ||
5521 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | 5558 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 2000) |
5522 | { | 5559 | { |
5523 | health+=1; | 5560 | health+=1; |
5524 | flags |= 2; | 5561 | flags |= 2; |
5525 | } | 5562 | } |
5526 | 5563 | ||
5527 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | 5564 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 2000) |
5528 | { | 5565 | { |
5529 | health+=1; | 5566 | health+=1; |
5530 | flags |= 4; | 5567 | flags |= 4; |
5531 | } | 5568 | } |
5569 | /* | ||
5532 | else | 5570 | else |
5533 | { | 5571 | { |
5534 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | 5572 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; |
@@ -5541,6 +5579,7 @@ proc.WaitForExit(); | |||
5541 | Thread.Sleep(1000); | 5579 | Thread.Sleep(1000); |
5542 | Environment.Exit(1); | 5580 | Environment.Exit(1); |
5543 | } | 5581 | } |
5582 | */ | ||
5544 | 5583 | ||
5545 | if (flags != 7) | 5584 | if (flags != 7) |
5546 | return health; | 5585 | return health; |
@@ -6305,6 +6344,32 @@ Environment.Exit(1); | |||
6305 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | 6344 | public void TimerWatchdog(object sender, ElapsedEventArgs e) |
6306 | { | 6345 | { |
6307 | CheckHeartbeat(); | 6346 | CheckHeartbeat(); |
6347 | |||
6348 | IEtcdModule etcd = RequestModuleInterface<IEtcdModule>(); | ||
6349 | int flags; | ||
6350 | string message; | ||
6351 | if (etcd != null) | ||
6352 | { | ||
6353 | int health = GetHealth(out flags, out message); | ||
6354 | if (health != m_lastHealth) | ||
6355 | { | ||
6356 | m_lastHealth = health; | ||
6357 | |||
6358 | etcd.Store("Health", health.ToString(), 300000); | ||
6359 | etcd.Store("HealthFlags", flags.ToString(), 300000); | ||
6360 | } | ||
6361 | |||
6362 | int roots = 0; | ||
6363 | foreach (ScenePresence sp in GetScenePresences()) | ||
6364 | if (!sp.IsChildAgent && !sp.IsNPC) | ||
6365 | roots++; | ||
6366 | |||
6367 | if (m_lastUsers != roots) | ||
6368 | { | ||
6369 | m_lastUsers = roots; | ||
6370 | etcd.Store("RootAgents", roots.ToString(), 300000); | ||
6371 | } | ||
6372 | } | ||
6308 | } | 6373 | } |
6309 | 6374 | ||
6310 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 6375 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 45196bb..bf4d60c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -376,6 +376,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
376 | public bool m_dupeInProgress = false; | 376 | public bool m_dupeInProgress = false; |
377 | internal Dictionary<UUID, string> m_savedScriptState; | 377 | internal Dictionary<UUID, string> m_savedScriptState; |
378 | 378 | ||
379 | public UUID MonitoringObject { get; set; } | ||
380 | |||
379 | #region Properties | 381 | #region Properties |
380 | 382 | ||
381 | /// <summary> | 383 | /// <summary> |
diff --git a/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs b/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs new file mode 100644 index 0000000..921bbfb --- /dev/null +++ b/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs | |||
@@ -0,0 +1,195 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Mono.Addins; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using netcd; | ||
41 | using netcd.Serialization; | ||
42 | using netcd.Advanced; | ||
43 | using netcd.Advanced.Requests; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Framework.Monitoring | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// Allows to store monitoring data in etcd, a high availability | ||
49 | /// name-value store. | ||
50 | /// </summary> | ||
51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EtcdMonitoringModule")] | ||
52 | public class EtcdMonitoringModule : INonSharedRegionModule, IEtcdModule | ||
53 | { | ||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | protected Scene m_scene; | ||
57 | protected IEtcdClient m_client; | ||
58 | protected bool m_enabled = false; | ||
59 | protected string m_etcdBasePath = String.Empty; | ||
60 | protected bool m_appendRegionID = true; | ||
61 | |||
62 | public string Name | ||
63 | { | ||
64 | get { return "EtcdMonitoringModule"; } | ||
65 | } | ||
66 | |||
67 | public Type ReplaceableInterface | ||
68 | { | ||
69 | get { return null; } | ||
70 | } | ||
71 | |||
72 | public void Initialise(IConfigSource source) | ||
73 | { | ||
74 | if (source.Configs["Etcd"] == null) | ||
75 | return; | ||
76 | |||
77 | IConfig etcdConfig = source.Configs["Etcd"]; | ||
78 | |||
79 | string etcdUrls = etcdConfig.GetString("EtcdUrls", String.Empty); | ||
80 | if (etcdUrls == String.Empty) | ||
81 | return; | ||
82 | |||
83 | m_etcdBasePath = etcdConfig.GetString("BasePath", m_etcdBasePath); | ||
84 | m_appendRegionID = etcdConfig.GetBoolean("AppendRegionID", m_appendRegionID); | ||
85 | |||
86 | if (!m_etcdBasePath.EndsWith("/")) | ||
87 | m_etcdBasePath += "/"; | ||
88 | |||
89 | try | ||
90 | { | ||
91 | string[] endpoints = etcdUrls.Split(new char[] {','}); | ||
92 | List<Uri> uris = new List<Uri>(); | ||
93 | foreach (string endpoint in endpoints) | ||
94 | uris.Add(new Uri(endpoint.Trim())); | ||
95 | |||
96 | m_client = new EtcdClient(uris.ToArray(), new DefaultSerializer(), new DefaultSerializer()); | ||
97 | } | ||
98 | catch (Exception e) | ||
99 | { | ||
100 | m_log.DebugFormat("[ETCD]: Error initializing connection: " + e.ToString()); | ||
101 | return; | ||
102 | } | ||
103 | |||
104 | m_log.DebugFormat("[ETCD]: Etcd module configured"); | ||
105 | m_enabled = true; | ||
106 | } | ||
107 | |||
108 | public void Close() | ||
109 | { | ||
110 | //m_client = null; | ||
111 | m_scene = null; | ||
112 | } | ||
113 | |||
114 | public void AddRegion(Scene scene) | ||
115 | { | ||
116 | m_scene = scene; | ||
117 | |||
118 | if (m_enabled) | ||
119 | { | ||
120 | if (m_appendRegionID) | ||
121 | m_etcdBasePath += m_scene.RegionInfo.RegionID.ToString() + "/"; | ||
122 | |||
123 | m_log.DebugFormat("[ETCD]: Using base path {0} for all keys", m_etcdBasePath); | ||
124 | |||
125 | try | ||
126 | { | ||
127 | m_client.Advanced.CreateDirectory(new CreateDirectoryRequest() {Key = m_etcdBasePath}); | ||
128 | } | ||
129 | catch (Exception e) | ||
130 | { | ||
131 | m_log.ErrorFormat("Exception trying to create base path {0}: " + e.ToString(), m_etcdBasePath); | ||
132 | } | ||
133 | |||
134 | scene.RegisterModuleInterface<IEtcdModule>(this); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | public void RemoveRegion(Scene scene) | ||
139 | { | ||
140 | } | ||
141 | |||
142 | public void RegionLoaded(Scene scene) | ||
143 | { | ||
144 | } | ||
145 | |||
146 | public bool Store(string k, string v) | ||
147 | { | ||
148 | return Store(k, v, 0); | ||
149 | } | ||
150 | |||
151 | public bool Store(string k, string v, int ttl) | ||
152 | { | ||
153 | Response resp = m_client.Advanced.SetKey(new SetKeyRequest() { Key = m_etcdBasePath + k, Value = v, TimeToLive = ttl }); | ||
154 | |||
155 | if (resp == null) | ||
156 | return false; | ||
157 | |||
158 | if (resp.ErrorCode.HasValue) | ||
159 | { | ||
160 | m_log.DebugFormat("[ETCD]: Error {0} ({1}) storing {2} => {3}", resp.Cause, (int)resp.ErrorCode, m_etcdBasePath + k, v); | ||
161 | |||
162 | return false; | ||
163 | } | ||
164 | |||
165 | return true; | ||
166 | } | ||
167 | |||
168 | public string Get(string k) | ||
169 | { | ||
170 | Response resp = m_client.Advanced.GetKey(new GetKeyRequest() { Key = m_etcdBasePath + k }); | ||
171 | |||
172 | if (resp == null) | ||
173 | return String.Empty; | ||
174 | |||
175 | if (resp.ErrorCode.HasValue) | ||
176 | { | ||
177 | m_log.DebugFormat("[ETCD]: Error {0} ({1}) getting {2}", resp.Cause, (int)resp.ErrorCode, m_etcdBasePath + k); | ||
178 | |||
179 | return String.Empty; | ||
180 | } | ||
181 | |||
182 | return resp.Node.Value; | ||
183 | } | ||
184 | |||
185 | public void Delete(string k) | ||
186 | { | ||
187 | m_client.Advanced.DeleteKey(new DeleteKeyRequest() { Key = m_etcdBasePath + k }); | ||
188 | } | ||
189 | |||
190 | public void Watch(string k, Action<string> callback) | ||
191 | { | ||
192 | m_client.Advanced.WatchKey(new WatchKeyRequest() { Key = m_etcdBasePath + k, Callback = (x) => { callback(x.Node.Value); } }); | ||
193 | } | ||
194 | } | ||
195 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3f2e321..62654ee 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -424,6 +424,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
424 | return lease; | 424 | return lease; |
425 | } | 425 | } |
426 | 426 | ||
427 | protected SceneObjectPart MonitoringObject() | ||
428 | { | ||
429 | UUID m = m_host.ParentGroup.MonitoringObject; | ||
430 | if (m == UUID.Zero) | ||
431 | return null; | ||
432 | |||
433 | SceneObjectPart p = m_ScriptEngine.World.GetSceneObjectPart(m); | ||
434 | if (p == null) | ||
435 | m_host.ParentGroup.MonitoringObject = UUID.Zero; | ||
436 | |||
437 | return p; | ||
438 | } | ||
439 | |||
427 | protected virtual void ScriptSleep(int delay) | 440 | protected virtual void ScriptSleep(int delay) |
428 | { | 441 | { |
429 | delay = (int)((float)delay * m_ScriptDelayFactor); | 442 | delay = (int)((float)delay * m_ScriptDelayFactor); |