From: Alan Webb <alan_webb@us.ibm.com>

Changes to AssetCache and DynamicTextureModule to eliminate
  opportunities for lost texture updates.
0.6.5-rc1
Dr Scofield 2009-03-24 08:21:50 +00:00
parent ec07baa8c0
commit b5f6aa6ff2
2 changed files with 46 additions and 20 deletions

View File

@ -350,7 +350,7 @@ namespace OpenSim.Framework.Communications.Cache
// If it's a direct request for a script, drop it // If it's a direct request for a script, drop it
// because it's a hacked client // because it's a hacked client
if (req.AssetRequestSource != 2 || assetInf.Type != 10) if (req.AssetRequestSource != 2 || assetInf.Type != 10)
AssetRequests.Add(req); lock(AssetRequests) AssetRequests.Add(req);
} }
} }
@ -487,7 +487,7 @@ namespace OpenSim.Framework.Communications.Cache
req.Params = transferRequest.TransferInfo.Params; req.Params = transferRequest.TransferInfo.Params;
req.AssetInf = new AssetInfo(asset); req.AssetInf = new AssetInfo(asset);
req.NumPackets = CalculateNumPackets(asset.Data); req.NumPackets = CalculateNumPackets(asset.Data);
AssetRequests.Add(req); lock(AssetRequests) AssetRequests.Add(req);
} }
/// <summary> /// <summary>
@ -506,16 +506,16 @@ namespace OpenSim.Framework.Communications.Cache
int num = Math.Min(5, AssetRequests.Count); int num = Math.Min(5, AssetRequests.Count);
AssetRequest req; AssetRequest req;
AssetRequestToClient req2 = null; AssetRequestToClient req2 = new AssetRequestToClient();
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
req = AssetRequests[i]; lock(AssetRequests)
if (req2 == null)
{ {
req2 = new AssetRequestToClient(); req = AssetRequests[0];
AssetRequests.RemoveAt(0);
} }
// Trying to limit memory usage by only creating AssetRequestToClient if needed
req2.AssetInf = req.AssetInf; req2.AssetInf = req.AssetInf;
req2.AssetRequestSource = req.AssetRequestSource; req2.AssetRequestSource = req.AssetRequestSource;
req2.DataPointer = req.DataPointer; req2.DataPointer = req.DataPointer;
@ -528,13 +528,9 @@ namespace OpenSim.Framework.Communications.Cache
req2.RequestAssetID = req.RequestAssetID; req2.RequestAssetID = req.RequestAssetID;
req2.TransferRequestID = req.TransferRequestID; req2.TransferRequestID = req.TransferRequestID;
req.RequestUser.SendAsset(req2); req.RequestUser.SendAsset(req2);
} }
//remove requests that have been completed
for (int i = 0; i < num; i++)
{
AssetRequests.RemoveAt(0);
}
} }
public class AssetRequest public class AssetRequest

View File

@ -65,16 +65,38 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
/// <param name="id"></param> /// <param name="id"></param>
/// <param name="data"></param> /// <param name="data"></param>
public void ReturnData(UUID id, byte[] data) public void ReturnData(UUID id, byte[] data)
{
DynamicTextureUpdater updater = null;
lock(Updaters)
{ {
if (Updaters.ContainsKey(id)) if (Updaters.ContainsKey(id))
{ {
DynamicTextureUpdater updater = Updaters[id]; updater = Updaters[id];
}
}
if(updater != null)
{
if (RegisteredScenes.ContainsKey(updater.SimUUID)) if (RegisteredScenes.ContainsKey(updater.SimUUID))
{ {
Scene scene = RegisteredScenes[updater.SimUUID]; Scene scene = RegisteredScenes[updater.SimUUID];
updater.DataReceived(data, scene); updater.DataReceived(data, scene);
} }
} }
if(updater.UpdateTimer == 0)
{
lock(Updaters)
{
if (!Updaters.ContainsKey(updater.UpdaterID))
{
Updaters.Remove(updater.UpdaterID);
}
}
}
} }
public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
@ -101,10 +123,13 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.BlendWithOldTexture = SetBlending; updater.BlendWithOldTexture = SetBlending;
updater.FrontAlpha = AlphaValue; updater.FrontAlpha = AlphaValue;
lock(Updaters)
{
if (!Updaters.ContainsKey(updater.UpdaterID)) if (!Updaters.ContainsKey(updater.UpdaterID))
{ {
Updaters.Add(updater.UpdaterID, updater); Updaters.Add(updater.UpdaterID, updater);
} }
}
RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
return updater.UpdaterID; return updater.UpdaterID;
@ -134,10 +159,13 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.BlendWithOldTexture = SetBlending; updater.BlendWithOldTexture = SetBlending;
updater.FrontAlpha = AlphaValue; updater.FrontAlpha = AlphaValue;
lock(Updaters)
{
if (!Updaters.ContainsKey(updater.UpdaterID)) if (!Updaters.ContainsKey(updater.UpdaterID))
{ {
Updaters.Add(updater.UpdaterID, updater); Updaters.Add(updater.UpdaterID, updater);
} }
}
RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
return updater.UpdaterID; return updater.UpdaterID;
@ -270,7 +298,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
// remove the old asset from the cache // remove the old asset from the cache
UUID oldID = tmptex.DefaultTexture.TextureID; UUID oldID = tmptex.DefaultTexture.TextureID;
scene.CommsManager.AssetCache.ExpireAsset(oldID);
tmptex.DefaultTexture.TextureID = asset.FullID; tmptex.DefaultTexture.TextureID = asset.FullID;
// I'm pretty sure we always want to force this to true // I'm pretty sure we always want to force this to true
@ -278,6 +305,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
part.Shape.Textures = tmptex; part.Shape.Textures = tmptex;
part.ScheduleFullUpdate(); part.ScheduleFullUpdate();
scene.CommsManager.AssetCache.ExpireAsset(oldID);
} }
private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha) private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha)