Added some terrain tests, and found a fun race condition in the sqlite

terrain driver in the process, which is now fixed.  yay for unit tests!
This commit is contained in:
Sean Dague
2008-09-16 19:51:14 +00:00
parent fe7a1af2bd
commit ad379ed136
3 changed files with 99 additions and 28 deletions

View File

@@ -470,6 +470,23 @@ namespace OpenSim.Data.SQLite
{
int revision = Util.UnixTimeSinceEpoch();
// This is added to get rid of the infinitely growing
// terrain databases which negatively impact on SQLite
// over time. Before reenabling this feature there
// needs to be a limitter put on the number of
// revisions in the database, as this old
// implementation is a DOS attack waiting to happen.
using (
SqliteCommand cmd =
new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision",
m_conn))
{
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID)));
cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
cmd.ExecuteNonQuery();
}
// the following is an work around for .NET. The perf
// issues associated with it aren't as bad as you think.
m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString());
@@ -483,23 +500,6 @@ namespace OpenSim.Data.SQLite
cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter)));
cmd.ExecuteNonQuery();
}
// This is added to get rid of the infinitely growing
// terrain databases which negatively impact on SQLite
// over time. Before reenabling this feature there
// needs to be a limitter put on the number of
// revisions in the database, as this old
// implementation is a DOS attack waiting to happen.
using (
SqliteCommand cmd =
new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision < :Revision",
m_conn))
{
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID)));
cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
cmd.ExecuteNonQuery();
}
}
}