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()
{
m_log.Info("[LOADREGIONS]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException (Name);
throw new PluginNotInitialisedException(Name);
}
public void Initialise(OpenSimBase openSim)

View File

@ -416,10 +416,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
// Security risk [and apparently not used]
// if (requestData.ContainsKey("datastore"))
// region.DataStore = (string) requestData["datastore"];
region.InternalEndPoint =
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];
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;
}

View File

@ -475,7 +475,7 @@ namespace OpenSim
{
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;
// set initial ServerURI
@ -517,7 +517,7 @@ namespace OpenSim
m_log.Info("[MODULES]: Loading scripting engine: " + mod);
try
{
m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene);
modules.AddRange(m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene));
}
catch (Exception ex)
{
@ -540,11 +540,13 @@ namespace OpenSim
{
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);
}
// 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.loadAllLandObjectsFromStorage(regionInfo.originRegionID);

View File

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

View File

@ -168,6 +168,7 @@ namespace OpenSim.Region.Environment.Scenes
// "[PRIM INVENTORY]: " +
// "Starting script {0}, {1} in prim {2}, {3}",
// item.Name, item.ItemID, Name, UUID);
if (!m_parentGroup.Scene.ExternalChecks.ExternalChecksCanRunScript(item.ItemID, UUID, item.OwnerID))
return;
@ -191,7 +192,8 @@ namespace OpenSim.Region.Environment.Scenes
m_taskInventory[item.ItemID].PermsMask = 0;
m_taskInventory[item.ItemID].PermsGranter = LLUUID.Zero;
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);
ScheduleFullUpdate();
}

View File

@ -196,7 +196,7 @@ namespace OpenSim.Region.Physics.Meshing
float startAngle = profileStart * twoPi;
float stopAngle = profileEnd * twoPi;
float stepSize = twoPi / sides;
// float stepSize = twoPi / sides;
try { angles.makeAngles(sides, startAngle, stopAngle); }
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)
/// </summary>
/// <returns></returns>
public Object InitializeLifetimeService()
public override Object InitializeLifetimeService()
{
//Console.WriteLine("Executor: InitializeLifetimeService()");
// return null;

View File

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