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>
private Dictionary<LLUUID, TextureImage> Textures;
/// <summary>
///
/// Assets requests which are waiting for asset server data. This includes texture requests
/// </summary>
private Dictionary<LLUUID, AssetRequest> RequestedAssets;
@ -76,6 +76,7 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary>
private List<AssetRequest> AssetRequests;
/// <summary>
/// Until the asset request is fulfilled, each asset request is associated with a list of requesters
/// </summary>
@ -242,9 +243,9 @@ namespace OpenSim.Framework.Communications.Cache
/// If the asset was not found this is still called with the asset UUID but with a null asset data reference</param>
public void GetAsset(LLUUID assetId, AssetRequestCallback callback, bool isTexture)
{
#if DEBUG
#if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: Requesting {0} {1}", isTexture ? "texture" : "asset", assetId);
#endif
#endif
AssetBase asset;
@ -254,9 +255,9 @@ namespace OpenSim.Framework.Communications.Cache
}
else
{
#if DEBUG
#if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: Adding request for {0} {1}", isTexture ? "texture" : "asset", assetId);
#endif
#endif
NewAssetRequest req = new NewAssetRequest(assetId, callback);
@ -390,17 +391,17 @@ namespace OpenSim.Framework.Communications.Cache
}
}
}
#if DEBUG
#if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result);
#endif
#endif
}
// See IAssetReceiver
public void AssetReceived(AssetBase asset, bool IsTexture)
{
#if DEBUG
#if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: Received {0} [{1}]", IsTexture ? "texture" : "asset", asset.FullID);
#endif
#endif
if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
{
@ -414,9 +415,9 @@ namespace OpenSim.Framework.Communications.Cache
TextureImage image = new TextureImage(asset);
if (Textures.ContainsKey(image.FullID))
{
#if DEBUG
#if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: There's already an texture {0} in memory. Skipping.", asset.FullID);
#endif
#endif
}
else
{
@ -433,9 +434,9 @@ namespace OpenSim.Framework.Communications.Cache
AssetInfo assetInf = new AssetInfo(asset);
if (Assets.ContainsKey(assetInf.FullID))
{
#if DEBUG
#if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: There's already an asset {0} in memory. Skipping.", asset.FullID);
#endif
#endif
}
else
{
@ -448,9 +449,9 @@ namespace OpenSim.Framework.Communications.Cache
if (RequestedAssets.ContainsKey(assetInf.FullID))
{
#if DEBUG
#if DEBUG
//m_log.DebugFormat("[ASSET CACHE]: Moving {0} from RequestedAssets to AssetRequests", asset.FullID);
#endif
#endif
AssetRequest req = RequestedAssets[assetInf.FullID];
req.AssetInf = assetInf;
@ -465,16 +466,33 @@ namespace OpenSim.Framework.Communications.Cache
// Notify requesters for this asset
if (RequestLists.ContainsKey(asset.FullID))
{
AssetRequestsList reqList = null;
lock (RequestLists)
{
AssetRequestsList reqList = RequestLists[asset.FullID];
foreach (NewAssetRequest req in reqList.Requests)
reqList = RequestLists[asset.FullID];
}
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);
}
RequestLists.Remove(asset.FullID);
reqList.Requests.Clear();
}
}
}