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

@ -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

@ -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

@ -168,6 +168,7 @@ namespace OpenSim.Region.Environment.Scenes
// "[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;
@ -191,7 +192,8 @@ namespace OpenSim.Region.Environment.Scenes
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,
startParam, postOnRez);
m_parentGroup.AddActiveScriptCount(1); m_parentGroup.AddActiveScriptCount(1);
ScheduleFullUpdate(); ScheduleFullUpdate();
} }

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

@ -165,11 +165,9 @@ 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;
@ -191,8 +189,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
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;
} }
@ -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
{ {
@ -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,13 +484,14 @@ 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 =
new ScriptInstance(this,localID,
part.UUID, itemID, assetID, assembly, part.UUID, itemID, assetID, assembly,
m_AppDomains[appDomain], m_AppDomains[appDomain],
part.ParentGroup.RootPart.Name, part.ParentGroup.RootPart.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));
} }
// //