From 7943ae48f506f23ac89fdcc0593c296c2cbf6540 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 23 Apr 2009 17:53:18 +0000 Subject: move the lock out a bit further in the ProccessAssetCache loop to reduce the number of times we are going to take this lock in a row (which is just wasted resource), and to keep us from attempting to array access a list which might be changing right now. Extremely curious if this helps prevent some of our mono segfaults. --- .../Framework/Communications/Cache/AssetCache.cs | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'OpenSim/Framework/Communications/Cache/AssetCache.cs') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index f214e19..7d25ca9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -515,7 +515,10 @@ namespace OpenSim.Framework.Communications.Cache req.Params = transferRequest.TransferInfo.Params; req.AssetInf = new AssetInfo(asset); req.NumPackets = CalculateNumPackets(asset.Data); - lock (AssetRequests) AssetRequests.Add(req); + lock (AssetRequests) + { + AssetRequests.Add(req); + } } /// @@ -536,26 +539,25 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req; AssetRequestToClient req2 = new AssetRequestToClient(); - for (int i = 0; i < num; i++) + lock (AssetRequests) { - lock (AssetRequests) + for (int i = 0; i < num; i++) { req = AssetRequests[0]; AssetRequests.RemoveAt(0); + req2.AssetInf = req.AssetInf; + req2.AssetRequestSource = req.AssetRequestSource; + req2.DataPointer = req.DataPointer; + req2.DiscardLevel = req.DiscardLevel; + req2.ImageInfo = req.ImageInfo; + req2.IsTextureRequest = req.IsTextureRequest; + req2.NumPackets = req.NumPackets; + req2.PacketCounter = req.PacketCounter; + req2.Params = req.Params; + req2.RequestAssetID = req.RequestAssetID; + req2.TransferRequestID = req.TransferRequestID; + req.RequestUser.SendAsset(req2); } - - req2.AssetInf = req.AssetInf; - req2.AssetRequestSource = req.AssetRequestSource; - req2.DataPointer = req.DataPointer; - req2.DiscardLevel = req.DiscardLevel; - req2.ImageInfo = req.ImageInfo; - req2.IsTextureRequest = req.IsTextureRequest; - req2.NumPackets = req.NumPackets; - req2.PacketCounter = req.PacketCounter; - req2.Params = req.Params; - req2.RequestAssetID = req.RequestAssetID; - req2.TransferRequestID = req.TransferRequestID; - req.RequestUser.SendAsset(req2); } } -- cgit v1.1