From 0d93069adb6be465f48c8588f707121e496ceabe Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 23 Oct 2007 14:31:35 +0000 Subject: add locking to the terrain database calls --- .../MonoSqliteDataStore.cs | 59 ++++++++++++---------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Storage') diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index c69200a..9188d10 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs @@ -233,12 +233,13 @@ namespace OpenSim.DataStore.MonoSqlite MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); DataTable terrain = ds.Tables["terrain"]; - - DataRow newrow = terrain.NewRow(); - fillTerrainRow(newrow, regionID, revision, ter); - terrain.Rows.Add(newrow); - - Commit(); + lock (ds) { + DataRow newrow = terrain.NewRow(); + fillTerrainRow(newrow, regionID, revision, ter); + terrain.Rows.Add(newrow); + + Commit(); + } } public double[,] LoadTerrain(LLUUID regionID) @@ -247,35 +248,37 @@ namespace OpenSim.DataStore.MonoSqlite terret.Initialize(); DataTable terrain = ds.Tables["terrain"]; + + lock (ds) { + DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC"); + + int rev = 0; - DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC"); - - 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; } -- cgit v1.1