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,14 +539,12 @@ namespace OpenSim.Framework.Communications.Cache
AssetRequest req;
AssetRequestToClient req2 = new AssetRequestToClient();
for (int i = 0; i < num; i++)
{
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;
@ -558,6 +559,7 @@ namespace OpenSim.Framework.Communications.Cache
req.RequestUser.SendAsset(req2);
}
}
}
public byte[] ProcessAssetData(byte[] assetData, IUserService userService)
{