guarantee that a script engine's GetScriptErrors() will not be called
until after its OnRezScript() returns so that script compile error messages can be retrievedavinationmerge
parent
58dac970af
commit
0b2b2daf23
|
@ -73,8 +73,6 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
|
void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
|
||||||
|
|
||||||
ArrayList GetScriptErrors(UUID itemID);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stop all the scripts in this entity.
|
/// Stop all the scripts in this entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -104,6 +102,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="stateSource"></param>
|
/// <param name="stateSource"></param>
|
||||||
void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
|
void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
|
||||||
|
|
||||||
|
ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stop a script which is in this prim's inventory.
|
/// Stop a script which is in this prim's inventory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -271,8 +271,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
// Needs to determine which engine was running it and use that
|
// Needs to determine which engine was running it and use that
|
||||||
//
|
//
|
||||||
part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0);
|
errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0);
|
||||||
errors = part.Inventory.GetScriptErrors(item.ItemID);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
private string m_inventoryFileName = String.Empty;
|
private string m_inventoryFileName = String.Empty;
|
||||||
private int m_inventoryFileNameSerial = 0;
|
private int m_inventoryFileNameSerial = 0;
|
||||||
|
|
||||||
|
private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>();
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The part to which the inventory belongs.
|
/// The part to which the inventory belongs.
|
||||||
/// </value>
|
/// </value>
|
||||||
|
@ -211,7 +213,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList GetScriptErrors(UUID itemID)
|
private ArrayList GetScriptErrors(UUID itemID)
|
||||||
{
|
{
|
||||||
ArrayList ret = new ArrayList();
|
ArrayList ret = new ArrayList();
|
||||||
|
|
||||||
|
@ -270,7 +272,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// item.Name, item.ItemID, Name, UUID);
|
// item.Name, item.ItemID, Name, UUID);
|
||||||
|
|
||||||
if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
|
if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
|
||||||
|
{
|
||||||
|
StoreScriptError(item.ItemID, "no permission");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_part.AddFlag(PrimFlags.Scripted);
|
m_part.AddFlag(PrimFlags.Scripted);
|
||||||
|
|
||||||
|
@ -285,6 +290,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_items.LockItemsForWrite(false);
|
m_items.LockItemsForWrite(false);
|
||||||
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
|
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
|
||||||
m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
|
m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
|
||||||
|
StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID));
|
||||||
m_part.ParentGroup.AddActiveScriptCount(1);
|
m_part.ParentGroup.AddActiveScriptCount(1);
|
||||||
m_part.ScheduleFullUpdate();
|
m_part.ScheduleFullUpdate();
|
||||||
return;
|
return;
|
||||||
|
@ -294,11 +300,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
if (null == asset)
|
if (null == asset)
|
||||||
{
|
{
|
||||||
|
string msg = String.Format("asset ID {0} could not be found", item.AssetID);
|
||||||
|
StoreScriptError(item.ItemID, msg);
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[PRIM INVENTORY]: " +
|
"[PRIM INVENTORY]: " +
|
||||||
"Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
|
"Couldn't start script {0}, {1} at {2} in {3} since {4}",
|
||||||
item.Name, item.ItemID, m_part.AbsolutePosition,
|
item.Name, item.ItemID, m_part.AbsolutePosition,
|
||||||
m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
|
m_part.ParentGroup.Scene.RegionInfo.RegionName, msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -311,11 +319,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
string script = Utils.BytesToString(asset.Data);
|
string script = Utils.BytesToString(asset.Data);
|
||||||
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
|
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
|
||||||
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
|
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
|
||||||
|
StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID));
|
||||||
m_part.ParentGroup.AddActiveScriptCount(1);
|
m_part.ParentGroup.AddActiveScriptCount(1);
|
||||||
m_part.ScheduleFullUpdate();
|
m_part.ScheduleFullUpdate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StoreScriptError(item.ItemID, "scripts disabled");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreSavedScriptState(UUID oldID, UUID newID)
|
private void RestoreSavedScriptState(UUID oldID, UUID newID)
|
||||||
|
@ -392,24 +405,71 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_items.LockItemsForRead(false);
|
m_items.LockItemsForRead(false);
|
||||||
|
string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID,
|
||||||
|
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||||
|
StoreScriptError(itemId, msg);
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[PRIM INVENTORY]: " +
|
"[PRIM INVENTORY]: " +
|
||||||
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
|
"Couldn't start script with ID {0} since it {1}", itemId, msg);
|
||||||
itemId, m_part.Name, m_part.UUID,
|
|
||||||
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_items.LockItemsForRead(false);
|
m_items.LockItemsForRead(false);
|
||||||
|
string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID);
|
||||||
|
StoreScriptError(itemId, msg);
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[PRIM INVENTORY]: " +
|
"[PRIM INVENTORY]: " +
|
||||||
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
|
"Couldn't start script with ID {0} since it {1}", itemId, msg);
|
||||||
itemId, m_part.Name, m_part.UUID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
|
||||||
|
{
|
||||||
|
ArrayList errors;
|
||||||
|
|
||||||
|
lock (m_scriptErrors)
|
||||||
|
{
|
||||||
|
m_scriptErrors.Remove(itemId);
|
||||||
|
}
|
||||||
|
CreateScriptInstance(itemId, startParam, postOnRez, engine, stateSource);
|
||||||
|
lock (m_scriptErrors)
|
||||||
|
{
|
||||||
|
while (!m_scriptErrors.TryGetValue(itemId, out errors))
|
||||||
|
{
|
||||||
|
if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000))
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[PRIM INVENTORY]: " +
|
||||||
|
"timedout waiting for script {0} errors", itemId);
|
||||||
|
if (!m_scriptErrors.TryGetValue(itemId, out errors))
|
||||||
|
{
|
||||||
|
errors = new ArrayList(1);
|
||||||
|
errors.Add("timedout waiting for errors");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_scriptErrors.Remove(itemId);
|
||||||
|
}
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
private void StoreScriptErrors(UUID itemId, ArrayList errors)
|
||||||
|
{
|
||||||
|
lock (m_scriptErrors)
|
||||||
|
{
|
||||||
|
m_scriptErrors[itemId] = errors;
|
||||||
|
System.Threading.Monitor.PulseAll(m_scriptErrors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void StoreScriptError(UUID itemId, string message)
|
||||||
|
{
|
||||||
|
ArrayList errors = new ArrayList(1);
|
||||||
|
errors.Add(message);
|
||||||
|
StoreScriptErrors(itemId, errors);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stop a script which is in this prim's inventory.
|
/// Stop a script which is in this prim's inventory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue