Added lock around World.Update to prevent multiple updates occuring simultaneously (it happened!)
parent
869b39c451
commit
6103e06a34
|
@ -41,6 +41,7 @@ namespace OpenSim.world
|
||||||
private string m_regionName;
|
private string m_regionName;
|
||||||
private InventoryCache _inventoryCache;
|
private InventoryCache _inventoryCache;
|
||||||
private AssetCache _assetCache;
|
private AssetCache _assetCache;
|
||||||
|
private int updateLock;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new World class, and a region to go with it.
|
/// Creates a new World class, and a region to go with it.
|
||||||
|
@ -52,6 +53,7 @@ namespace OpenSim.world
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
updateLock = 0;
|
||||||
m_clientThreads = clientThreads;
|
m_clientThreads = clientThreads;
|
||||||
m_regionHandle = regionHandle;
|
m_regionHandle = regionHandle;
|
||||||
m_regionName = regionName;
|
m_regionName = regionName;
|
||||||
|
@ -183,48 +185,51 @@ namespace OpenSim.world
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
try
|
lock (updateLock)
|
||||||
{
|
{
|
||||||
if (this.phyScene.IsThreaded)
|
try
|
||||||
{
|
{
|
||||||
this.phyScene.GetResults();
|
if (this.phyScene.IsThreaded)
|
||||||
|
{
|
||||||
|
this.phyScene.GetResults();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
|
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
|
||||||
{
|
{
|
||||||
Entities[UUID].addForces();
|
Entities[UUID].addForces();
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (this.LockPhysicsEngine)
|
lock (this.LockPhysicsEngine)
|
||||||
{
|
{
|
||||||
this.phyScene.Simulate(timeStep);
|
this.phyScene.Simulate(timeStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
|
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
|
||||||
{
|
{
|
||||||
Entities[UUID].update();
|
Entities[UUID].update();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
|
foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
|
||||||
{
|
{
|
||||||
scriptHandler.OnFrame();
|
scriptHandler.OnFrame();
|
||||||
|
}
|
||||||
|
foreach (IScriptEngine scripteng in this.scriptEngines.Values)
|
||||||
|
{
|
||||||
|
scripteng.OnFrame();
|
||||||
|
}
|
||||||
|
//backup world data
|
||||||
|
this.storageCount++;
|
||||||
|
if (storageCount > 1200) //set to how often you want to backup
|
||||||
|
{
|
||||||
|
this.Backup();
|
||||||
|
storageCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach (IScriptEngine scripteng in this.scriptEngines.Values)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
scripteng.OnFrame();
|
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString());
|
||||||
}
|
}
|
||||||
//backup world data
|
|
||||||
this.storageCount++;
|
|
||||||
if (storageCount > 1200) //set to how often you want to backup
|
|
||||||
{
|
|
||||||
this.Backup();
|
|
||||||
storageCount = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue