From a1e2fea7c1fc612da088914aab7a462c212bc97d Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 11 Sep 2007 08:25:32 +0000 Subject: [PATCH] move the locks closer to the data, sqlite for assets now works like a champ --- .../Communications/Cache/AssetCache.cs | 12 +--- .../Framework/Data.SQLite/SQLiteAssetData.cs | 65 ++++++++++--------- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 8a16f03dfd..2f4c006058 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -200,10 +200,7 @@ namespace OpenSim.Framework.Communications.Caches //Console.WriteLine("new texture to send"); TextureSender sender = new TextureSender(req); //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); } @@ -263,11 +260,8 @@ namespace OpenSim.Framework.Communications.Caches { 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); } } diff --git a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs index aef9350aac..4616275cbe 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs @@ -61,19 +61,20 @@ namespace OpenSim.Framework.Data.SQLite ds = new DataSet(); 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; } @@ -110,19 +111,19 @@ namespace OpenSim.Framework.Data.SQLite ", Local: " + asset.Local + ", Data Length: " + asset.Data.Length ); DataTable assets = ds.Tables["assets"]; - DataRow row = assets.Rows.Find(asset.FullID); - if (row == null) - { - row = assets.NewRow(); - fillAssetRow(row, asset); - assets.Rows.Add(row); + lock(ds) { + DataRow row = assets.Rows.Find(asset.FullID); + if (row == null) + { + row = assets.NewRow(); + 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) @@ -133,19 +134,21 @@ namespace OpenSim.Framework.Data.SQLite public void DeleteAsset(LLUUID uuid) { - DataRow row = ds.Tables["assets"].Rows.Find(uuid); - if (row != null) { - row.Delete(); + lock (ds) { + DataRow row = ds.Tables["assets"].Rows.Find(uuid); + if (row != null) { + row.Delete(); + } } - da.Update(ds, "assets"); - ds.AcceptChanges(); } public void CommitAssets() // force a sync to the database { MainLog.Instance.Verbose("AssetStorage", "Attempting commit"); - // da.Update(ds, "assets"); - // ds.AcceptChanges(); + lock (ds) { + da.Update(ds, "assets"); + ds.AcceptChanges(); + } } /***********************************************************************