Hopefully fixed the bug that was causing a lot of the freezing. Which was happening due to locks in the AssetCache and Texturedownload module. Where the thread from the Asset thread would be take a lock on a list in the asset cache and then try to call the Callback into the texturedownload module and hit a lock in there which was held by a ClientView thread- which at the same time would be trying to request another texture from the cache and be hitting the lock in there held by the IClientAPI. The result each thread waiting for the other one to release a lock. And as one of those was the ClientView process packet thread. No more packets from that client could be processed. For now I've made a copy of the list in AssetCache so that it can release the lock. I'm doing more work on assets (moving the client asset downloading to a module ), so will hopefully change this into a better method once I've cleaned over things up a bit.

0.6.0-stable
MW 2008-02-27 14:40:30 +00:00
parent 0b7f10efed
commit a9ae5ab840
1 changed files with 51 additions and 33 deletions

View File

@ -66,7 +66,7 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary> /// </summary>
private Dictionary<LLUUID, TextureImage> Textures; private Dictionary<LLUUID, TextureImage> Textures;
/// <summary> ///
/// Assets requests which are waiting for asset server data. This includes texture requests /// Assets requests which are waiting for asset server data. This includes texture requests
/// </summary> /// </summary>
private Dictionary<LLUUID, AssetRequest> RequestedAssets; private Dictionary<LLUUID, AssetRequest> RequestedAssets;
@ -76,6 +76,7 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary> /// </summary>
private List<AssetRequest> AssetRequests; private List<AssetRequest> AssetRequests;
/// <summary> /// <summary>
/// Until the asset request is fulfilled, each asset request is associated with a list of requesters /// Until the asset request is fulfilled, each asset request is associated with a list of requesters
/// </summary> /// </summary>
@ -465,16 +466,33 @@ namespace OpenSim.Framework.Communications.Cache
// Notify requesters for this asset // Notify requesters for this asset
if (RequestLists.ContainsKey(asset.FullID)) if (RequestLists.ContainsKey(asset.FullID))
{ {
AssetRequestsList reqList = null;
lock (RequestLists) lock (RequestLists)
{ {
AssetRequestsList reqList = RequestLists[asset.FullID]; reqList = RequestLists[asset.FullID];
foreach (NewAssetRequest req in reqList.Requests)
}
if (reqList != null)
{
//making a copy of the list is not ideal
//but the old method of locking around this whole block of code was causing a multi-thread lock
//between this and the TextureDownloadModule
//while the localAsset thread running this and trying to send a texture to the callback in the
//texturedownloadmodule , and hitting a lock in there. While the texturedownload thread (which was holding
// the lock in the texturedownload module) was trying to
//request a new asset and hitting a lock in here on the RequestLists.
List<NewAssetRequest> theseRequests = new List<NewAssetRequest>(reqList.Requests);
reqList.Requests.Clear();
lock (RequestLists)
{
RequestLists.Remove(asset.FullID);
}
foreach (NewAssetRequest req in theseRequests)
{ {
req.Callback(asset.FullID, asset); req.Callback(asset.FullID, asset);
} }
RequestLists.Remove(asset.FullID);
reqList.Requests.Clear();
} }
} }
} }