aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world
diff options
context:
space:
mode:
authorAdam Frisby2007-04-22 18:00:01 +0000
committerAdam Frisby2007-04-22 18:00:01 +0000
commit6103e06a3425de19213746e1cd6933fa2468c979 (patch)
tree696e54dcb6e51a7f1c75ac4dcc9289e77c005db3 /OpenSim.RegionServer/world
parentSimClient: Added Try/Catch over block of code which is triggering an exceptio... (diff)
downloadopensim-SC_OLD-6103e06a3425de19213746e1cd6933fa2468c979.zip
opensim-SC_OLD-6103e06a3425de19213746e1cd6933fa2468c979.tar.gz
opensim-SC_OLD-6103e06a3425de19213746e1cd6933fa2468c979.tar.bz2
opensim-SC_OLD-6103e06a3425de19213746e1cd6933fa2468c979.tar.xz
Added lock around World.Update to prevent multiple updates occuring simultaneously (it happened!)
Diffstat (limited to 'OpenSim.RegionServer/world')
-rw-r--r--OpenSim.RegionServer/world/World.cs69
1 files changed, 37 insertions, 32 deletions
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index 693db4d..0291467 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -41,6 +41,7 @@ namespace OpenSim.world
41 private string m_regionName; 41 private string m_regionName;
42 private InventoryCache _inventoryCache; 42 private InventoryCache _inventoryCache;
43 private AssetCache _assetCache; 43 private AssetCache _assetCache;
44 private int updateLock;
44 45
45 /// <summary> 46 /// <summary>
46 /// Creates a new World class, and a region to go with it. 47 /// Creates a new World class, and a region to go with it.
@@ -52,6 +53,7 @@ namespace OpenSim.world
52 { 53 {
53 try 54 try
54 { 55 {
56 updateLock = 0;
55 m_clientThreads = clientThreads; 57 m_clientThreads = clientThreads;
56 m_regionHandle = regionHandle; 58 m_regionHandle = regionHandle;
57 m_regionName = regionName; 59 m_regionName = regionName;
@@ -183,49 +185,52 @@ namespace OpenSim.world
183 /// </summary> 185 /// </summary>
184 public void Update() 186 public void Update()
185 { 187 {
186 try 188 lock (updateLock)
187 { 189 {
188 if (this.phyScene.IsThreaded) 190 try
189 { 191 {
190 this.phyScene.GetResults(); 192 if (this.phyScene.IsThreaded)
193 {
194 this.phyScene.GetResults();
191 195
192 } 196 }
193 197
194 foreach (libsecondlife.LLUUID UUID in Entities.Keys) 198 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
195 { 199 {
196 Entities[UUID].addForces(); 200 Entities[UUID].addForces();
197 } 201 }
198 202
199 lock (this.LockPhysicsEngine) 203 lock (this.LockPhysicsEngine)
200 { 204 {
201 this.phyScene.Simulate(timeStep); 205 this.phyScene.Simulate(timeStep);
202 } 206 }
203 207
204 foreach (libsecondlife.LLUUID UUID in Entities.Keys) 208 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
205 { 209 {
206 Entities[UUID].update(); 210 Entities[UUID].update();
207 } 211 }
208 212
209 foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values) 213 foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
210 { 214 {
211 scriptHandler.OnFrame(); 215 scriptHandler.OnFrame();
212 } 216 }
213 foreach (IScriptEngine scripteng in this.scriptEngines.Values) 217 foreach (IScriptEngine scripteng in this.scriptEngines.Values)
214 { 218 {
215 scripteng.OnFrame(); 219 scripteng.OnFrame();
220 }
221 //backup world data
222 this.storageCount++;
223 if (storageCount > 1200) //set to how often you want to backup
224 {
225 this.Backup();
226 storageCount = 0;
227 }
216 } 228 }
217 //backup world data 229 catch (Exception e)
218 this.storageCount++;
219 if (storageCount > 1200) //set to how often you want to backup
220 { 230 {
221 this.Backup(); 231 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString());
222 storageCount = 0;
223 } 232 }
224 } 233 }
225 catch (Exception e)
226 {
227 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString());
228 }
229 } 234 }
230 235
231 /// <summary> 236 /// <summary>