aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorSean Dague2007-10-23 14:31:35 +0000
committerSean Dague2007-10-23 14:31:35 +0000
commit0d93069adb6be465f48c8588f707121e496ceabe (patch)
treef4b66e885e94fa4acb4f5ed6339437f316034d67 /OpenSim/Region
parent* Fix for issue#514 - Sim crash when editing near terrain edge. (diff)
downloadopensim-SC-0d93069adb6be465f48c8588f707121e496ceabe.zip
opensim-SC-0d93069adb6be465f48c8588f707121e496ceabe.tar.gz
opensim-SC-0d93069adb6be465f48c8588f707121e496ceabe.tar.bz2
opensim-SC-0d93069adb6be465f48c8588f707121e496ceabe.tar.xz
add locking to the terrain database calls
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs59
1 files changed, 31 insertions, 28 deletions
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
233 MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); 233 MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString());
234 234
235 DataTable terrain = ds.Tables["terrain"]; 235 DataTable terrain = ds.Tables["terrain"];
236 236 lock (ds) {
237 DataRow newrow = terrain.NewRow(); 237 DataRow newrow = terrain.NewRow();
238 fillTerrainRow(newrow, regionID, revision, ter); 238 fillTerrainRow(newrow, regionID, revision, ter);
239 terrain.Rows.Add(newrow); 239 terrain.Rows.Add(newrow);
240 240
241 Commit(); 241 Commit();
242 }
242 } 243 }
243 244
244 public double[,] LoadTerrain(LLUUID regionID) 245 public double[,] LoadTerrain(LLUUID regionID)
@@ -247,35 +248,37 @@ namespace OpenSim.DataStore.MonoSqlite
247 terret.Initialize(); 248 terret.Initialize();
248 249
249 DataTable terrain = ds.Tables["terrain"]; 250 DataTable terrain = ds.Tables["terrain"];
251
252 lock (ds) {
253 DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC");
254
255 int rev = 0;
250 256
251 DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC"); 257 if (rows.Length > 0)
252
253 int rev = 0;
254
255 if (rows.Length > 0)
256 {
257 DataRow row = rows[0];
258
259 byte[] heightmap = (byte[])row["Heightfield"];
260 for (int x = 0; x < 256; x++)
261 { 258 {
262 for (int y = 0; y < 256; y++) 259 DataRow row = rows[0];
260
261 byte[] heightmap = (byte[])row["Heightfield"];
262 for (int x = 0; x < 256; x++)
263 { 263 {
264 terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8); 264 for (int y = 0; y < 256; y++)
265 } 265 {
266 terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8);
267 }
268 }
269
270 rev = (int)row["Revision"];
271 }
272 else
273 {
274 MainLog.Instance.Verbose("DATASTORE", "No terrain found for region");
275 return null;
266 } 276 }
267 277
268 rev = (int)row["Revision"]; 278
269 } 279 MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString());
270 else
271 {
272 MainLog.Instance.Verbose("DATASTORE", "No terrain found for region");
273 return null;
274 } 280 }
275 281
276
277 MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString());
278
279 return terret; 282 return terret;
280 } 283 }
281 284