diff options
Diffstat (limited to 'OpenSim/Region/Framework')
6 files changed, 144 insertions, 17 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index f58904f..16ca3f9 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -73,8 +73,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
73 | /// </summary> | 73 | /// </summary> |
74 | void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); | 74 | void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); |
75 | 75 | ||
76 | ArrayList GetScriptErrors(UUID itemID); | ||
77 | |||
78 | /// <summary> | 76 | /// <summary> |
79 | /// Stop all the scripts in this entity. | 77 | /// Stop all the scripts in this entity. |
80 | /// </summary> | 78 | /// </summary> |
@@ -104,6 +102,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
104 | /// <param name="stateSource"></param> | 102 | /// <param name="stateSource"></param> |
105 | void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); | 103 | void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); |
106 | 104 | ||
105 | ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); | ||
106 | |||
107 | /// <summary> | 107 | /// <summary> |
108 | /// Stop a script which is in this prim's inventory. | 108 | /// Stop a script which is in this prim's inventory. |
109 | /// </summary> | 109 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs b/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs new file mode 100644 index 0000000..6fd6ba7 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs | |||
@@ -0,0 +1,12 @@ | |||
1 | /////////////////////////////////////////////////////////////////// | ||
2 | // | ||
3 | // (c) Careminster LImited, Melanie Thielker and the Meta7 Team | ||
4 | // | ||
5 | // This file is not open source. All rights reserved | ||
6 | // Mod 2 | ||
7 | public interface ISnmpModule | ||
8 | { | ||
9 | void Alert(string message); | ||
10 | void Trap(int code,string simname,string Message); | ||
11 | void ColdStart(int step , string simname); | ||
12 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1875c48..357cdc4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -212,8 +212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
212 | { | 212 | { |
213 | // Needs to determine which engine was running it and use that | 213 | // Needs to determine which engine was running it and use that |
214 | // | 214 | // |
215 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 215 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0); |
216 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
217 | } | 216 | } |
218 | else | 217 | else |
219 | { | 218 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e4daa0b..671f8fc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -156,6 +156,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | 156 | ||
157 | public IXfer XferManager; | 157 | public IXfer XferManager; |
158 | 158 | ||
159 | protected ISnmpModule m_snmpService = null; | ||
160 | public ISnmpModule SnmpService | ||
161 | { | ||
162 | get | ||
163 | { | ||
164 | if (m_snmpService == null) | ||
165 | { | ||
166 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
167 | } | ||
168 | |||
169 | return m_snmpService; | ||
170 | } | ||
171 | } | ||
172 | |||
159 | protected IAssetService m_AssetService; | 173 | protected IAssetService m_AssetService; |
160 | protected IAuthorizationService m_AuthorizationService; | 174 | protected IAuthorizationService m_AuthorizationService; |
161 | 175 | ||
@@ -1727,7 +1741,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1727 | public void SaveTerrain() | 1741 | public void SaveTerrain() |
1728 | { | 1742 | { |
1729 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1743 | m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |
1730 | } | 1744 | } |
1731 | 1745 | ||
1732 | public void StoreWindlightProfile(RegionLightShareData wl) | 1746 | public void StoreWindlightProfile(RegionLightShareData wl) |
1733 | { | 1747 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 014b007..84c3719 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -104,8 +104,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | /// since the group's last persistent backup | 104 | /// since the group's last persistent backup |
105 | /// </summary> | 105 | /// </summary> |
106 | private bool m_hasGroupChanged = false; | 106 | private bool m_hasGroupChanged = false; |
107 | private long timeFirstChanged; | 107 | private long timeFirstChanged = 0; |
108 | private long timeLastChanged; | 108 | private long timeLastChanged = 0; |
109 | private long m_maxPersistTime = 0; | ||
110 | private long m_minPersistTime = 0; | ||
111 | private Random m_rand; | ||
112 | |||
109 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); | 113 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); |
110 | 114 | ||
111 | public void lockPartsForRead(bool locked) | 115 | public void lockPartsForRead(bool locked) |
@@ -182,6 +186,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | timeLastChanged = DateTime.Now.Ticks; | 186 | timeLastChanged = DateTime.Now.Ticks; |
183 | if (!m_hasGroupChanged) | 187 | if (!m_hasGroupChanged) |
184 | timeFirstChanged = DateTime.Now.Ticks; | 188 | timeFirstChanged = DateTime.Now.Ticks; |
189 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
190 | { | ||
191 | if (m_rand == null) | ||
192 | { | ||
193 | byte[] val = new byte[16]; | ||
194 | m_rootPart.UUID.ToBytes(val, 0); | ||
195 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
196 | } | ||
197 | |||
198 | if (m_scene.GetRootAgentCount() == 0) | ||
199 | { | ||
200 | //If the region is empty, this change has been made by an automated process | ||
201 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
202 | |||
203 | float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
204 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
205 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
210 | //but add a random factor so we stagger the object persistance a little | ||
211 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
212 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
213 | } | ||
214 | } | ||
185 | } | 215 | } |
186 | m_hasGroupChanged = value; | 216 | m_hasGroupChanged = value; |
187 | } | 217 | } |
@@ -197,8 +227,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
197 | return false; | 227 | return false; |
198 | if (m_scene.ShuttingDown) | 228 | if (m_scene.ShuttingDown) |
199 | return true; | 229 | return true; |
230 | |||
231 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
232 | { | ||
233 | m_maxPersistTime = m_scene.m_persistAfter; | ||
234 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
235 | } | ||
236 | |||
200 | long currentTime = DateTime.Now.Ticks; | 237 | long currentTime = DateTime.Now.Ticks; |
201 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 238 | |
239 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
240 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
241 | |||
242 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
202 | return true; | 243 | return true; |
203 | return false; | 244 | return false; |
204 | } | 245 | } |
@@ -530,6 +571,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
530 | /// </summary> | 571 | /// </summary> |
531 | public SceneObjectGroup() | 572 | public SceneObjectGroup() |
532 | { | 573 | { |
574 | |||
533 | } | 575 | } |
534 | 576 | ||
535 | /// <summary> | 577 | /// <summary> |
@@ -546,7 +588,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
546 | /// Constructor. This object is added to the scene later via AttachToScene() | 588 | /// Constructor. This object is added to the scene later via AttachToScene() |
547 | /// </summary> | 589 | /// </summary> |
548 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 590 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
549 | { | 591 | { |
550 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); | 592 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
551 | } | 593 | } |
552 | 594 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 836622d..07d58a1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -45,6 +45,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
45 | 45 | ||
46 | private string m_inventoryFileName = String.Empty; | 46 | private string m_inventoryFileName = String.Empty; |
47 | private int m_inventoryFileNameSerial = 0; | 47 | private int m_inventoryFileNameSerial = 0; |
48 | |||
49 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
48 | 50 | ||
49 | /// <value> | 51 | /// <value> |
50 | /// The part to which the inventory belongs. | 52 | /// The part to which the inventory belongs. |
@@ -210,7 +212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
210 | } | 212 | } |
211 | } | 213 | } |
212 | 214 | ||
213 | public ArrayList GetScriptErrors(UUID itemID) | 215 | private ArrayList GetScriptErrors(UUID itemID) |
214 | { | 216 | { |
215 | ArrayList ret = new ArrayList(); | 217 | ArrayList ret = new ArrayList(); |
216 | 218 | ||
@@ -269,7 +271,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
269 | // item.Name, item.ItemID, Name, UUID); | 271 | // item.Name, item.ItemID, Name, UUID); |
270 | 272 | ||
271 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 273 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
274 | { | ||
275 | StoreScriptError(item.ItemID, "no permission"); | ||
272 | return; | 276 | return; |
277 | } | ||
273 | 278 | ||
274 | m_part.AddFlag(PrimFlags.Scripted); | 279 | m_part.AddFlag(PrimFlags.Scripted); |
275 | 280 | ||
@@ -284,6 +289,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
284 | m_items.LockItemsForWrite(false); | 289 | m_items.LockItemsForWrite(false); |
285 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 290 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
286 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 291 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
292 | StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID)); | ||
287 | m_part.ParentGroup.AddActiveScriptCount(1); | 293 | m_part.ParentGroup.AddActiveScriptCount(1); |
288 | m_part.ScheduleFullUpdate(); | 294 | m_part.ScheduleFullUpdate(); |
289 | return; | 295 | return; |
@@ -293,11 +299,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
293 | { | 299 | { |
294 | if (null == asset) | 300 | if (null == asset) |
295 | { | 301 | { |
302 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
303 | StoreScriptError(item.ItemID, msg); | ||
296 | m_log.ErrorFormat( | 304 | m_log.ErrorFormat( |
297 | "[PRIM INVENTORY]: " + | 305 | "[PRIM INVENTORY]: " + |
298 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 306 | "Couldn't start script {0}, {1} at {2} in {3} since {4}", |
299 | item.Name, item.ItemID, m_part.AbsolutePosition, | 307 | item.Name, item.ItemID, m_part.AbsolutePosition, |
300 | m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); | 308 | m_part.ParentGroup.Scene.RegionInfo.RegionName, msg); |
301 | } | 309 | } |
302 | else | 310 | else |
303 | { | 311 | { |
@@ -310,11 +318,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
310 | string script = Utils.BytesToString(asset.Data); | 318 | string script = Utils.BytesToString(asset.Data); |
311 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 319 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
312 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 320 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
321 | StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID)); | ||
313 | m_part.ParentGroup.AddActiveScriptCount(1); | 322 | m_part.ParentGroup.AddActiveScriptCount(1); |
314 | m_part.ScheduleFullUpdate(); | 323 | m_part.ScheduleFullUpdate(); |
315 | } | 324 | } |
316 | }); | 325 | }); |
317 | } | 326 | } |
327 | else | ||
328 | { | ||
329 | StoreScriptError(item.ItemID, "scripts disabled"); | ||
330 | } | ||
318 | } | 331 | } |
319 | 332 | ||
320 | private void RestoreSavedScriptState(UUID oldID, UUID newID) | 333 | private void RestoreSavedScriptState(UUID oldID, UUID newID) |
@@ -391,24 +404,71 @@ namespace OpenSim.Region.Framework.Scenes | |||
391 | else | 404 | else |
392 | { | 405 | { |
393 | m_items.LockItemsForRead(false); | 406 | m_items.LockItemsForRead(false); |
407 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, | ||
408 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
409 | StoreScriptError(itemId, msg); | ||
394 | m_log.ErrorFormat( | 410 | m_log.ErrorFormat( |
395 | "[PRIM INVENTORY]: " + | 411 | "[PRIM INVENTORY]: " + |
396 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 412 | "Couldn't start script with ID {0} since it {1}", itemId, msg); |
397 | itemId, m_part.Name, m_part.UUID, | ||
398 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
399 | } | 413 | } |
400 | } | 414 | } |
401 | else | 415 | else |
402 | { | 416 | { |
403 | m_items.LockItemsForRead(false); | 417 | m_items.LockItemsForRead(false); |
418 | string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); | ||
419 | StoreScriptError(itemId, msg); | ||
404 | m_log.ErrorFormat( | 420 | m_log.ErrorFormat( |
405 | "[PRIM INVENTORY]: " + | 421 | "[PRIM INVENTORY]: " + |
406 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | 422 | "Couldn't start script with ID {0} since it {1}", itemId, msg); |
407 | itemId, m_part.Name, m_part.UUID); | ||
408 | } | 423 | } |
409 | 424 | ||
410 | } | 425 | } |
411 | 426 | ||
427 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
428 | { | ||
429 | ArrayList errors; | ||
430 | |||
431 | lock (m_scriptErrors) | ||
432 | { | ||
433 | m_scriptErrors.Remove(itemId); | ||
434 | } | ||
435 | CreateScriptInstance(itemId, startParam, postOnRez, engine, stateSource); | ||
436 | lock (m_scriptErrors) | ||
437 | { | ||
438 | while (!m_scriptErrors.TryGetValue(itemId, out errors)) | ||
439 | { | ||
440 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
441 | { | ||
442 | m_log.ErrorFormat( | ||
443 | "[PRIM INVENTORY]: " + | ||
444 | "timedout waiting for script {0} errors", itemId); | ||
445 | if (!m_scriptErrors.TryGetValue(itemId, out errors)) | ||
446 | { | ||
447 | errors = new ArrayList(1); | ||
448 | errors.Add("timedout waiting for errors"); | ||
449 | } | ||
450 | break; | ||
451 | } | ||
452 | } | ||
453 | m_scriptErrors.Remove(itemId); | ||
454 | } | ||
455 | return errors; | ||
456 | } | ||
457 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
458 | { | ||
459 | lock (m_scriptErrors) | ||
460 | { | ||
461 | m_scriptErrors[itemId] = errors; | ||
462 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
463 | } | ||
464 | } | ||
465 | private void StoreScriptError(UUID itemId, string message) | ||
466 | { | ||
467 | ArrayList errors = new ArrayList(1); | ||
468 | errors.Add(message); | ||
469 | StoreScriptErrors(itemId, errors); | ||
470 | } | ||
471 | |||
412 | /// <summary> | 472 | /// <summary> |
413 | /// Stop a script which is in this prim's inventory. | 473 | /// Stop a script which is in this prim's inventory. |
414 | /// </summary> | 474 | /// </summary> |