From 0770a5de0a53c9b539891e6a993724628668a489 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 11 Sep 2007 04:54:55 +0000 Subject: Trying some locks on asset database access. --- .../Communications/Cache/SQLAssetServer.cs | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index fc4efc5..a965ee0 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -44,7 +44,8 @@ namespace OpenSim.Framework.Communications.Caches private IAssetReceiver _receiver; private BlockingQueue _assetRequests; private Thread _localAssetServerThread; - protected IAssetProvider m_plugin; + protected IAssetProvider m_plugin; + private object syncLock = new object(); public SQLAssetServer() @@ -101,15 +102,21 @@ namespace OpenSim.Framework.Communications.Caches } public void UpdateAsset(AssetBase asset) - { - m_plugin.UpdateAsset(asset); - m_plugin.CommitAssets(); + { + lock (syncLock) + { + m_plugin.UpdateAsset(asset); + m_plugin.CommitAssets(); + } } public void CreateAsset(AssetBase asset) - { - m_plugin.CreateAsset(asset); - m_plugin.CommitAssets(); + { + lock (syncLock) + { + m_plugin.CreateAsset(asset); + m_plugin.CommitAssets(); + } } public void SetServerInfo(string ServerUrl, string ServerKey) @@ -128,9 +135,13 @@ namespace OpenSim.Framework.Communications.Caches { ARequest req = this._assetRequests.Dequeue(); - MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); - - AssetBase asset = m_plugin.FetchAsset(req.AssetID); + MainLog.Instance.Verbose("Requesting asset: " + req.AssetID); + + AssetBase asset = null; + lock (syncLock) + { + asset = m_plugin.FetchAsset(req.AssetID); + } if (asset != null) { _receiver.AssetReceived(asset, req.IsTexture); -- cgit v1.1