* Added static mutex to terrain load-tile to prevent file IO locking issues.

afrisby
Adam Frisby 2007-10-25 15:17:42 +00:00
parent 2048d611cf
commit 6804f9affb
1 changed files with 37 additions and 26 deletions
OpenSim/Region/Terrain.BasicTerrain

View File

@ -51,6 +51,8 @@ namespace OpenSim.Region.Terrain
public class TerrainEngine
{
public static System.Threading.Mutex fileIOLock = new System.Threading.Mutex();
/// <summary>
/// Plugin library for scripts
/// </summary>
@ -731,6 +733,10 @@ namespace OpenSim.Region.Terrain
/// <param name="lowerboundY">Where do the region coords start for this terrain?</param>
public void LoadFromFileF32(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY)
{
fileIOLock.WaitOne();
try
{
int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w);
int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h);
@ -745,7 +751,7 @@ namespace OpenSim.Region.Terrain
{
for (y = 0; y < dimensionY; y++)
{
tempMap[x,y] = (double)bs.ReadSingle();
tempMap[x, y] = (double)bs.ReadSingle();
}
}
@ -762,6 +768,11 @@ namespace OpenSim.Region.Terrain
tainted++;
}
finally
{
fileIOLock.ReleaseMutex();
}
}
/// <summary>
/// Loads a larger tiled image across a terrain