fix: PostInitialise() not being called on script engines (nasty one that)

cleanup: warnings, readability
0.6.0-stable
Dr Scofield 2008-09-02 12:07:23 +00:00
parent f13a48fe1c
commit 109aa00150
9 changed files with 81 additions and 84 deletions

View File

@ -52,7 +52,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
public void Initialise() public void Initialise()
{ {
m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name); throw new PluginNotInitialisedException(Name);
} }
public void Initialise(OpenSimBase openSim) public void Initialise(OpenSimBase openSim)

View File

@ -416,10 +416,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
// Security risk [and apparently not used]
// if (requestData.ContainsKey("datastore"))
// region.DataStore = (string) requestData["datastore"];
region.InternalEndPoint = region.InternalEndPoint =
new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0);

View File

@ -70,7 +70,7 @@ namespace OpenSim.Framework.RegionLoader.Filesystem
RegionInfo[] regionInfos = new RegionInfo[configFiles.Length]; RegionInfo[] regionInfos = new RegionInfo[configFiles.Length];
for (int i = 0; i < configFiles.Length; i++) for (int i = 0; i < configFiles.Length; i++)
{ {
RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i],false); RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i], false);
regionInfos[i] = regionInfo; regionInfos[i] = regionInfo;
} }

View File

@ -475,7 +475,7 @@ namespace OpenSim
{ {
int port = regionInfo.InternalEndPoint.Port; int port = regionInfo.InternalEndPoint.Port;
// set initial RegionID to originRegionID in RegionInfo. (it needs for loding prims) // set initial originRegionID to RegionID in RegionInfo. (it needs for loding prims)
regionInfo.originRegionID = regionInfo.RegionID; regionInfo.originRegionID = regionInfo.RegionID;
// set initial ServerURI // set initial ServerURI
@ -517,7 +517,7 @@ namespace OpenSim
m_log.Info("[MODULES]: Loading scripting engine: " + mod); m_log.Info("[MODULES]: Loading scripting engine: " + mod);
try try
{ {
m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene); modules.AddRange(m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -540,11 +540,13 @@ namespace OpenSim
{ {
m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e); m_log.ErrorFormat("[STARTUP]: Registration of region with grid failed, aborting startup - {0}", e);
// Carrying on now causes a lot of confusion down the line - we need to get the user's attention // Carrying on now causes a lot of confusion down the
// line - we need to get the user's attention
System.Environment.Exit(1); System.Environment.Exit(1);
} }
// We need to do this after we've initialized the scripting engines. // We need to do this after we've initialized the
// scripting engines.
scene.CreateScriptInstances(); scene.CreateScriptInstances();
scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID); scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);

View File

@ -123,10 +123,10 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
{ {
try try
{ {
#pragma warning disable 0612 #pragma warning disable 0612, 0618
// Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this!
ServicePointManager.CertificatePolicy = new MonoCert(); ServicePointManager.CertificatePolicy = new MonoCert();
#pragma warning restore 0612 #pragma warning restore 0612, 0618
} }
catch (Exception) catch (Exception)
{ {

View File

@ -164,10 +164,11 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns> /// <returns></returns>
public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez) public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez)
{ {
// m_log.InfoFormat( // m_log.InfoFormat(
// "[PRIM INVENTORY]: " + // "[PRIM INVENTORY]: " +
// "Starting script {0}, {1} in prim {2}, {3}", // "Starting script {0}, {1} in prim {2}, {3}",
// item.Name, item.ItemID, Name, UUID); // item.Name, item.ItemID, Name, UUID);
if (!m_parentGroup.Scene.ExternalChecks.ExternalChecksCanRunScript(item.ItemID, UUID, item.OwnerID)) if (!m_parentGroup.Scene.ExternalChecks.ExternalChecksCanRunScript(item.ItemID, UUID, item.OwnerID))
return; return;
@ -178,24 +179,25 @@ namespace OpenSim.Region.Environment.Scenes
AssetCache cache = m_parentGroup.Scene.AssetCache; AssetCache cache = m_parentGroup.Scene.AssetCache;
cache.GetAsset(item.AssetID, delegate(LLUUID assetID, AssetBase asset) cache.GetAsset(item.AssetID, delegate(LLUUID assetID, AssetBase asset)
{ {
if (null == asset) if (null == asset)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: " +
"Couldn't start script {0}, {1} since asset ID {2} could not be found", "Couldn't start script {0}, {1} since asset ID {2} could not be found",
item.Name, item.ItemID, item.AssetID); item.Name, item.ItemID, item.AssetID);
} }
else else
{ {
m_taskInventory[item.ItemID].PermsMask = 0; m_taskInventory[item.ItemID].PermsMask = 0;
m_taskInventory[item.ItemID].PermsGranter = LLUUID.Zero; m_taskInventory[item.ItemID].PermsGranter = LLUUID.Zero;
string script = Helpers.FieldToUTF8String(asset.Data); string script = Helpers.FieldToUTF8String(asset.Data);
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID,script, startParam, postOnRez); m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script,
m_parentGroup.AddActiveScriptCount(1); startParam, postOnRez);
ScheduleFullUpdate(); m_parentGroup.AddActiveScriptCount(1);
} ScheduleFullUpdate();
}, false); }
}, false);
} }
} }

View File

@ -196,7 +196,7 @@ namespace OpenSim.Region.Physics.Meshing
float startAngle = profileStart * twoPi; float startAngle = profileStart * twoPi;
float stopAngle = profileEnd * twoPi; float stopAngle = profileEnd * twoPi;
float stepSize = twoPi / sides; // float stepSize = twoPi / sides;
try { angles.makeAngles(sides, startAngle, stopAngle); } try { angles.makeAngles(sides, startAngle, stopAngle); }
catch (Exception ex) catch (Exception ex)

View File

@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
/// Make sure our object does not timeout when in AppDomain. (Called by ILease base class) /// Make sure our object does not timeout when in AppDomain. (Called by ILease base class)
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public Object InitializeLifetimeService() public override Object InitializeLifetimeService()
{ {
//Console.WriteLine("Executor: InitializeLifetimeService()"); //Console.WriteLine("Executor: InitializeLifetimeService()");
// return null; // return null;

View File

@ -145,11 +145,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void Initialise(Scene scene, IConfigSource configSource) public void Initialise(Scene scene, IConfigSource configSource)
{ {
AppDomain.CurrentDomain.AssemblyResolve += AppDomain.CurrentDomain.AssemblyResolve +=
OnAssemblyResolve; OnAssemblyResolve;
m_log.InfoFormat("[XEngine] Initializing scripts in region {0}", m_log.InfoFormat("[XEngine] Initializing scripts in region {0}",
scene.RegionInfo.RegionName); scene.RegionInfo.RegionName);
m_Scene=scene; m_Scene = scene;
m_ScriptConfig = configSource.Configs["XEngine"]; m_ScriptConfig = configSource.Configs["XEngine"];
@ -165,34 +165,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine
string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); string priority = m_ScriptConfig.GetString("Priority", "BelowNormal");
int maxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); int maxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300);
int stackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); int stackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144);
int sleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", int sleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10)*1000;
10)*1000;
m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30);
m_KillTimedOutScripts = m_ScriptConfig.GetBoolean( m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false);
"KillTimedOutScripts", false);
int saveTime = m_ScriptConfig.GetInt("SaveInterval", 300)*1000; int saveTime = m_ScriptConfig.GetInt("SaveInterval", 300)*1000;
ThreadPriority prio = ThreadPriority.BelowNormal; ThreadPriority prio = ThreadPriority.BelowNormal;
switch (priority) switch (priority)
{ {
case "Lowest": case "Lowest":
prio=ThreadPriority.Lowest; prio = ThreadPriority.Lowest;
break; break;
case "BelowNormal": case "BelowNormal":
prio=ThreadPriority.BelowNormal; prio = ThreadPriority.BelowNormal;
break; break;
case "Normal": case "Normal":
prio=ThreadPriority.Normal; prio = ThreadPriority.Normal;
break; break;
case "AboveNormal": case "AboveNormal":
prio=ThreadPriority.AboveNormal; prio = ThreadPriority.AboveNormal;
break; break;
case "Highest": case "Highest":
prio=ThreadPriority.Highest; prio = ThreadPriority.Highest;
break; break;
default: default:
m_log.ErrorFormat("[XEngine] Invalid thread priority: '"+ m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority);
priority+"'. Assuming BelowNormal");
break; break;
} }
@ -204,7 +201,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_EventManager = new EventManager(this); m_EventManager = new EventManager(this);
StartEngine(minThreads, maxThreads, idleTimeout, prio, StartEngine(minThreads, maxThreads, idleTimeout, prio,
maxScriptQueue, stackSize); maxScriptQueue, stackSize);
m_Compiler = new Compiler(this); m_Compiler = new Compiler(this);
@ -218,15 +215,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (sleepTime > 0) if (sleepTime > 0)
{ {
m_ThreadPool.QueueWorkItem(new WorkItemCallback( m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
this.DoMaintenance), new Object[] new Object[]{ sleepTime });
{ sleepTime });
} }
if (saveTime > 0) if (saveTime > 0)
{ {
m_ThreadPool.QueueWorkItem(new WorkItemCallback( m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup),
this.DoBackup), new Object[] { saveTime }); new Object[] { saveTime });
} }
scene.RegisterModuleInterface<IScriptModule>(this); scene.RegisterModuleInterface<IScriptModule>(this);
@ -279,8 +275,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
instances.Clear(); instances.Clear();
m_ThreadPool.QueueWorkItem(new WorkItemCallback( m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup),
this.DoBackup), new Object[] { saveTime }); new Object[] { saveTime });
return 0; return 0;
} }
@ -302,9 +298,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
System.Threading.Thread.Sleep(sleepTime); System.Threading.Thread.Sleep(sleepTime);
m_ThreadPool.QueueWorkItem(new WorkItemCallback( m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
this.DoMaintenance), new Object[] new Object[]{ sleepTime });
{ sleepTime });
return 0; return 0;
} }
@ -321,25 +316,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez) public void OnRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez)
{ {
Object[] parms = new Object[] Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez};
{ localID, itemID, script, startParam, postOnRez};
lock (m_CompileQueue) lock (m_CompileQueue)
{ {
m_CompileQueue.Enqueue(parms); m_CompileQueue.Enqueue(parms);
if (m_CurrentCompile == null) if (m_CurrentCompile == null)
{ {
if (m_firstStart) if (m_firstStart)
{ {
m_firstStart = false; m_firstStart = false;
m_CurrentCompile = m_ThreadPool.QueueWorkItem( m_CurrentCompile = m_ThreadPool.QueueWorkItem(
new WorkItemCallback( new WorkItemCallback(this.DoScriptWait),
this.DoScriptWait), new Object[0]); new Object[0]);
return; return;
} }
m_CurrentCompile = m_ThreadPool.QueueWorkItem( m_CurrentCompile = m_ThreadPool.QueueWorkItem(
new WorkItemCallback( new WorkItemCallback(this.DoOnRezScriptQueue),
this.DoOnRezScriptQueue), new Object[0]); new Object[0]);
} }
} }
} }
@ -353,8 +349,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (m_CompileQueue.Count > 0) if (m_CompileQueue.Count > 0)
{ {
m_CurrentCompile = m_ThreadPool.QueueWorkItem( m_CurrentCompile = m_ThreadPool.QueueWorkItem(
new WorkItemCallback( new WorkItemCallback(this.DoOnRezScriptQueue),
this.DoOnRezScriptQueue), new Object[0]); new Object[0]);
} }
else else
{ {
@ -384,8 +380,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (m_CompileQueue.Count > 0) if (m_CompileQueue.Count > 0)
{ {
m_CurrentCompile = m_ThreadPool.QueueWorkItem( m_CurrentCompile = m_ThreadPool.QueueWorkItem(
new WorkItemCallback( new WorkItemCallback(this.DoOnRezScriptQueue),
this.DoOnRezScriptQueue), new Object[0]); new Object[0]);
} }
else else
{ {
@ -459,7 +455,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if ((!m_Scripts.ContainsKey(itemID)) || if ((!m_Scripts.ContainsKey(itemID)) ||
(m_Scripts[itemID].AssetID != assetID)) (m_Scripts[itemID].AssetID != assetID))
{ {
LLUUID appDomain=assetID; LLUUID appDomain = assetID;
if (part.ParentGroup.RootPart.IsAttachment) if (part.ParentGroup.RootPart.IsAttachment)
appDomain = part.ParentGroup.RootPart.UUID; appDomain = part.ParentGroup.RootPart.UUID;
@ -473,8 +469,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// "ScriptEngines", // "ScriptEngines",
// m_Scene.RegionInfo.RegionID.ToString()); // m_Scene.RegionInfo.RegionID.ToString());
Evidence baseEvidence = Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
AppDomain.CurrentDomain.Evidence;
Evidence evidence = new Evidence(baseEvidence); Evidence evidence = new Evidence(baseEvidence);
m_AppDomains[appDomain] = m_AppDomains[appDomain] =
@ -489,18 +484,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Error("[XEngine] Exception creating app domain:\n"+e.ToString()); m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString());
return false; return false;
} }
} }
m_DomainScripts[appDomain].Add(itemID); m_DomainScripts[appDomain].Add(itemID);
ScriptInstance instance = new ScriptInstance(this,localID, ScriptInstance instance =
part.UUID, itemID, assetID, assembly, new ScriptInstance(this,localID,
m_AppDomains[appDomain], part.UUID, itemID, assetID, assembly,
part.ParentGroup.RootPart.Name, m_AppDomains[appDomain],
item.Name, startParam, postOnRez, part.ParentGroup.RootPart.Name,
StateSource.NewRez, m_MaxScriptQueue); item.Name, startParam, postOnRez,
StateSource.NewRez, m_MaxScriptQueue);
m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", m_log.DebugFormat("[XEngine] Loaded script {0}.{1}",
part.ParentGroup.RootPart.Name, item.Name); part.ParentGroup.RootPart.Name, item.Name);
@ -657,8 +653,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// //
public IScriptWorkItem QueueEventHandler(object parms) public IScriptWorkItem QueueEventHandler(object parms)
{ {
return new XWorkItem(m_ThreadPool.QueueWorkItem(new WorkItemCallback( return new XWorkItem(m_ThreadPool.QueueWorkItem(
this.ProcessEventHandler), parms)); new WorkItemCallback(this.ProcessEventHandler),
parms));
} }
// //