move the locks closer to the data, sqlite for assets now works like a champ

afrisby
Sean Dague 2007-09-11 08:25:32 +00:00
parent b3777729b4
commit a1e2fea7c1
2 changed files with 37 additions and 40 deletions

View File

@ -200,10 +200,7 @@ namespace OpenSim.Framework.Communications.Caches
//Console.WriteLine("new texture to send"); //Console.WriteLine("new texture to send");
TextureSender sender = new TextureSender(req); TextureSender sender = new TextureSender(req);
//sender.OnComplete += this.TextureSent; //sender.OnComplete += this.TextureSent;
lock (this.SendingTextures) this.SendingTextures.Add(req.ImageInfo.FullID, sender);
{
this.SendingTextures.Add(req.ImageInfo.FullID, sender);
}
this.QueueTextures.Enqueue(sender); this.QueueTextures.Enqueue(sender);
} }
@ -263,11 +260,8 @@ namespace OpenSim.Framework.Communications.Caches
{ {
if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
{ {
lock (this.SendingTextures) this.SendingTextures.Remove(sender.request.ImageInfo.FullID);
{ // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID);
this.SendingTextures.Remove(sender.request.ImageInfo.FullID);
// this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID);
}
} }
} }

View File

@ -61,19 +61,20 @@ namespace OpenSim.Framework.Data.SQLite
ds = new DataSet(); ds = new DataSet();
da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn)); da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn));
ds.Tables.Add(createAssetsTable());
setupAssetCommands(da, conn);
try
{
da.Fill(ds.Tables["assets"]);
}
catch (Exception)
{
MainLog.Instance.Verbose("AssetStorage", "Caught fill error on asset table");
}
lock (ds) {
ds.Tables.Add(createAssetsTable());
setupAssetCommands(da, conn);
try
{
da.Fill(ds.Tables["assets"]);
}
catch (Exception)
{
MainLog.Instance.Verbose("AssetStorage", "Caught fill error on asset table");
}
}
return; return;
} }
@ -110,19 +111,19 @@ namespace OpenSim.Framework.Data.SQLite
", Local: " + asset.Local + ", Local: " + asset.Local +
", Data Length: " + asset.Data.Length ); ", Data Length: " + asset.Data.Length );
DataTable assets = ds.Tables["assets"]; DataTable assets = ds.Tables["assets"];
DataRow row = assets.Rows.Find(asset.FullID); lock(ds) {
if (row == null) DataRow row = assets.Rows.Find(asset.FullID);
{ if (row == null)
row = assets.NewRow(); {
fillAssetRow(row, asset); row = assets.NewRow();
assets.Rows.Add(row); fillAssetRow(row, asset);
assets.Rows.Add(row);
}
else
{
fillAssetRow(row, asset);
}
} }
else
{
fillAssetRow(row, asset);
}
da.Update(ds, "assets");
ds.AcceptChanges();
} }
public bool ExistsAsset(LLUUID uuid) public bool ExistsAsset(LLUUID uuid)
@ -133,19 +134,21 @@ namespace OpenSim.Framework.Data.SQLite
public void DeleteAsset(LLUUID uuid) public void DeleteAsset(LLUUID uuid)
{ {
DataRow row = ds.Tables["assets"].Rows.Find(uuid); lock (ds) {
if (row != null) { DataRow row = ds.Tables["assets"].Rows.Find(uuid);
row.Delete(); if (row != null) {
row.Delete();
}
} }
da.Update(ds, "assets");
ds.AcceptChanges();
} }
public void CommitAssets() // force a sync to the database public void CommitAssets() // force a sync to the database
{ {
MainLog.Instance.Verbose("AssetStorage", "Attempting commit"); MainLog.Instance.Verbose("AssetStorage", "Attempting commit");
// da.Update(ds, "assets"); lock (ds) {
// ds.AcceptChanges(); da.Update(ds, "assets");
ds.AcceptChanges();
}
} }
/*********************************************************************** /***********************************************************************