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.
0.6.5-rc1
Sean Dague 2009-04-23 17:53:18 +00:00
parent 31bded51fb
commit 7943ae48f5
1 changed files with 18 additions and 16 deletions

View File

@ -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);
}
}
/// <summary>
@ -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);
}
}