add locking to the terrain database calls

afrisby
Sean Dague 2007-10-23 14:31:35 +00:00
parent 42318dc15a
commit 0d93069adb
1 changed files with 31 additions and 28 deletions

View File

@ -233,12 +233,13 @@ namespace OpenSim.DataStore.MonoSqlite
MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString());
DataTable terrain = ds.Tables["terrain"];
lock (ds) {
DataRow newrow = terrain.NewRow();
fillTerrainRow(newrow, regionID, revision, ter);
terrain.Rows.Add(newrow);
DataRow newrow = terrain.NewRow();
fillTerrainRow(newrow, regionID, revision, ter);
terrain.Rows.Add(newrow);
Commit();
Commit();
}
}
public double[,] LoadTerrain(LLUUID regionID)
@ -248,33 +249,35 @@ namespace OpenSim.DataStore.MonoSqlite
DataTable terrain = ds.Tables["terrain"];
DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC");
lock (ds) {
DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC");
int rev = 0;
int rev = 0;
if (rows.Length > 0)
{
DataRow row = rows[0];
byte[] heightmap = (byte[])row["Heightfield"];
for (int x = 0; x < 256; x++)
if (rows.Length > 0)
{
for (int y = 0; y < 256; y++)
DataRow row = rows[0];
byte[] heightmap = (byte[])row["Heightfield"];
for (int x = 0; x < 256; x++)
{
terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8);
for (int y = 0; y < 256; y++)
{
terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8);
}
}
rev = (int)row["Revision"];
}
else
{
MainLog.Instance.Verbose("DATASTORE", "No terrain found for region");
return null;
}
rev = (int)row["Revision"];
}
else
{
MainLog.Instance.Verbose("DATASTORE", "No terrain found for region");
return null;
}
MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString());
MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString());
}
return terret;
}