aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorMike Rieker2010-04-10 14:43:26 -0400
committerMike Rieker2010-04-10 14:43:26 -0400
commit0b2b2daf23dbf7a51f3d568903548cd964334ce2 (patch)
tree48fdbe61315cb18a1e5182e36abfd50e88f409d2 /OpenSim/Region/Framework
parentre-fixing this darn file (diff)
downloadopensim-SC_OLD-0b2b2daf23dbf7a51f3d568903548cd964334ce2.zip
opensim-SC_OLD-0b2b2daf23dbf7a51f3d568903548cd964334ce2.tar.gz
opensim-SC_OLD-0b2b2daf23dbf7a51f3d568903548cd964334ce2.tar.bz2
opensim-SC_OLD-0b2b2daf23dbf7a51f3d568903548cd964334ce2.tar.xz
guarantee that a script engine's GetScriptErrors() will not be called
until after its OnRezScript() returns so that script compile error messages can be retrieved
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs76
3 files changed, 71 insertions, 12 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/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b04871e..6c57d18 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -271,8 +271,7 @@ namespace OpenSim.Region.Framework.Scenes
271 { 271 {
272 // Needs to determine which engine was running it and use that 272 // Needs to determine which engine was running it and use that
273 // 273 //
274 part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); 274 errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0);
275 errors = part.Inventory.GetScriptErrors(item.ItemID);
276 } 275 }
277 else 276 else
278 { 277 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 5d00917..d03b464 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -46,6 +46,8 @@ namespace OpenSim.Region.Framework.Scenes
46 46
47 private string m_inventoryFileName = String.Empty; 47 private string m_inventoryFileName = String.Empty;
48 private int m_inventoryFileNameSerial = 0; 48 private int m_inventoryFileNameSerial = 0;
49
50 private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>();
49 51
50 /// <value> 52 /// <value>
51 /// The part to which the inventory belongs. 53 /// The part to which the inventory belongs.
@@ -211,7 +213,7 @@ namespace OpenSim.Region.Framework.Scenes
211 } 213 }
212 } 214 }
213 215
214 public ArrayList GetScriptErrors(UUID itemID) 216 private ArrayList GetScriptErrors(UUID itemID)
215 { 217 {
216 ArrayList ret = new ArrayList(); 218 ArrayList ret = new ArrayList();
217 219
@@ -270,7 +272,10 @@ namespace OpenSim.Region.Framework.Scenes
270 // item.Name, item.ItemID, Name, UUID); 272 // item.Name, item.ItemID, Name, UUID);
271 273
272 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 274 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
275 {
276 StoreScriptError(item.ItemID, "no permission");
273 return; 277 return;
278 }
274 279
275 m_part.AddFlag(PrimFlags.Scripted); 280 m_part.AddFlag(PrimFlags.Scripted);
276 281
@@ -285,6 +290,7 @@ namespace OpenSim.Region.Framework.Scenes
285 m_items.LockItemsForWrite(false); 290 m_items.LockItemsForWrite(false);
286 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 291 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
287 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 292 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
293 StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID));
288 m_part.ParentGroup.AddActiveScriptCount(1); 294 m_part.ParentGroup.AddActiveScriptCount(1);
289 m_part.ScheduleFullUpdate(); 295 m_part.ScheduleFullUpdate();
290 return; 296 return;
@@ -294,11 +300,13 @@ namespace OpenSim.Region.Framework.Scenes
294 { 300 {
295 if (null == asset) 301 if (null == asset)
296 { 302 {
303 string msg = String.Format("asset ID {0} could not be found", item.AssetID);
304 StoreScriptError(item.ItemID, msg);
297 m_log.ErrorFormat( 305 m_log.ErrorFormat(
298 "[PRIM INVENTORY]: " + 306 "[PRIM INVENTORY]: " +
299 "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 307 "Couldn't start script {0}, {1} at {2} in {3} since {4}",
300 item.Name, item.ItemID, m_part.AbsolutePosition, 308 item.Name, item.ItemID, m_part.AbsolutePosition,
301 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 309 m_part.ParentGroup.Scene.RegionInfo.RegionName, msg);
302 } 310 }
303 else 311 else
304 { 312 {
@@ -311,11 +319,16 @@ namespace OpenSim.Region.Framework.Scenes
311 string script = Utils.BytesToString(asset.Data); 319 string script = Utils.BytesToString(asset.Data);
312 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 320 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
313 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); 321 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
322 StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID));
314 m_part.ParentGroup.AddActiveScriptCount(1); 323 m_part.ParentGroup.AddActiveScriptCount(1);
315 m_part.ScheduleFullUpdate(); 324 m_part.ScheduleFullUpdate();
316 } 325 }
317 }); 326 });
318 } 327 }
328 else
329 {
330 StoreScriptError(item.ItemID, "scripts disabled");
331 }
319 } 332 }
320 333
321 private void RestoreSavedScriptState(UUID oldID, UUID newID) 334 private void RestoreSavedScriptState(UUID oldID, UUID newID)
@@ -392,24 +405,71 @@ namespace OpenSim.Region.Framework.Scenes
392 else 405 else
393 { 406 {
394 m_items.LockItemsForRead(false); 407 m_items.LockItemsForRead(false);
408 string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID,
409 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
410 StoreScriptError(itemId, msg);
395 m_log.ErrorFormat( 411 m_log.ErrorFormat(
396 "[PRIM INVENTORY]: " + 412 "[PRIM INVENTORY]: " +
397 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", 413 "Couldn't start script with ID {0} since it {1}", itemId, msg);
398 itemId, m_part.Name, m_part.UUID,
399 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
400 } 414 }
401 } 415 }
402 else 416 else
403 { 417 {
404 m_items.LockItemsForRead(false); 418 m_items.LockItemsForRead(false);
419 string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID);
420 StoreScriptError(itemId, msg);
405 m_log.ErrorFormat( 421 m_log.ErrorFormat(
406 "[PRIM INVENTORY]: " + 422 "[PRIM INVENTORY]: " +
407 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", 423 "Couldn't start script with ID {0} since it {1}", itemId, msg);
408 itemId, m_part.Name, m_part.UUID);
409 } 424 }
410 425
411 } 426 }
412 427
428 public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
429 {
430 ArrayList errors;
431
432 lock (m_scriptErrors)
433 {
434 m_scriptErrors.Remove(itemId);
435 }
436 CreateScriptInstance(itemId, startParam, postOnRez, engine, stateSource);
437 lock (m_scriptErrors)
438 {
439 while (!m_scriptErrors.TryGetValue(itemId, out errors))
440 {
441 if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000))
442 {
443 m_log.ErrorFormat(
444 "[PRIM INVENTORY]: " +
445 "timedout waiting for script {0} errors", itemId);
446 if (!m_scriptErrors.TryGetValue(itemId, out errors))
447 {
448 errors = new ArrayList(1);
449 errors.Add("timedout waiting for errors");
450 }
451 break;
452 }
453 }
454 m_scriptErrors.Remove(itemId);
455 }
456 return errors;
457 }
458 private void StoreScriptErrors(UUID itemId, ArrayList errors)
459 {
460 lock (m_scriptErrors)
461 {
462 m_scriptErrors[itemId] = errors;
463 System.Threading.Monitor.PulseAll(m_scriptErrors);
464 }
465 }
466 private void StoreScriptError(UUID itemId, string message)
467 {
468 ArrayList errors = new ArrayList(1);
469 errors.Add(message);
470 StoreScriptErrors(itemId, errors);
471 }
472
413 /// <summary> 473 /// <summary>
414 /// Stop a script which is in this prim's inventory. 474 /// Stop a script which is in this prim's inventory.
415 /// </summary> 475 /// </summary>