add some locks back into the sqlite asset path, as something changed

that is causing a lot of out of order execution on asset fetches on
multi region sims.
0.6.0-stable
Sean Dague 2008-07-18 15:34:32 +00:00
parent 0ea73384d4
commit 611b56070b
1 changed files with 56 additions and 49 deletions

View File

@ -94,22 +94,24 @@ namespace OpenSim.Data.SQLite
/// <returns>Asset base</returns> /// <returns>Asset base</returns>
override public AssetBase FetchAsset(LLUUID uuid) override public AssetBase FetchAsset(LLUUID uuid)
{ {
lock(this)
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
{ {
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(uuid))); using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
using (IDataReader reader = cmd.ExecuteReader())
{ {
if (reader.Read()) cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(uuid)));
using (IDataReader reader = cmd.ExecuteReader())
{ {
AssetBase asset = buildAsset(reader); if (reader.Read())
reader.Close(); {
return asset; AssetBase asset = buildAsset(reader);
} reader.Close();
else return asset;
{ }
reader.Close(); else
return null; {
reader.Close();
return null;
}
} }
} }
} }
@ -128,17 +130,19 @@ namespace OpenSim.Data.SQLite
} }
else else
{ {
using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn)) lock(this) {
{ using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn))
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(asset.FullID))); {
cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(asset.FullID)));
cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
}
} }
} }
} }
@ -151,19 +155,20 @@ namespace OpenSim.Data.SQLite
{ {
LogAssetLoad(asset); LogAssetLoad(asset);
using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn)) lock(this) {
{ using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn))
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(asset.FullID))); {
cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name)); cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(asset.FullID)));
cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description)); cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
}
} }
} }
/// <summary> /// <summary>
@ -190,20 +195,22 @@ namespace OpenSim.Data.SQLite
/// <returns>True if exist, or false.</returns> /// <returns>True if exist, or false.</returns>
override public bool ExistsAsset(LLUUID uuid) override public bool ExistsAsset(LLUUID uuid)
{ {
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) lock (this) {
{ using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(uuid)));
using (IDataReader reader = cmd.ExecuteReader())
{ {
if (reader.Read()) cmd.Parameters.Add(new SqliteParameter(":UUID", Util.ToRawUuidString(uuid)));
using (IDataReader reader = cmd.ExecuteReader())
{ {
reader.Close(); if (reader.Read())
return true; {
} reader.Close();
else return true;
{ }
reader.Close(); else
return false; {
reader.Close();
return false;
}
} }
} }
} }