* Fixed xml loading bug (the xml was scheduled for update before added to a scene)

* Fixed ClickAction situation on the same note (properties shouldn't cause big changes)
* Added some more debug output to AssetCache
ThreadPoolClientBranch
lbsa71 2008-02-20 09:38:45 +00:00
parent bf42637ee8
commit 9be5f9d6cc
4 changed files with 107 additions and 78 deletions

View File

@ -109,8 +109,8 @@ namespace OpenSim.Framework.Communications.Cache
temporaryAssets); temporaryAssets);
m_log.InfoFormat("Image data: {0}kb Asset data: {1}kb", m_log.InfoFormat("Image data: {0}kb Asset data: {1}kb",
imageBytes/1024, imageBytes / 1024,
assetBytes/1024); assetBytes / 1024);
} }
@ -141,7 +141,6 @@ namespace OpenSim.Framework.Communications.Cache
m_assetServer = assetServer; m_assetServer = assetServer;
m_assetServer.SetReceiver(this); m_assetServer.SetReceiver(this);
m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
m_assetCacheThread.Name = "AssetCacheThread"; m_assetCacheThread.Name = "AssetCacheThread";
m_assetCacheThread.IsBackground = true; m_assetCacheThread.IsBackground = true;
@ -170,59 +169,72 @@ namespace OpenSim.Framework.Communications.Cache
/// <summary> /// <summary>
/// Only get an asset if we already have it in the cache. /// Only get an asset if we already have it in the cache.
/// </summary> /// </summary>
/// <param name="assetID"></param></param> /// <param name="assetId"></param></param>
/// <returns></returns> /// <returns></returns>
private AssetBase GetCachedAsset(LLUUID assetID) //private AssetBase GetCachedAsset(LLUUID assetId)
//{
// AssetBase asset = null;
// if (Textures.ContainsKey(assetId))
// {
// asset = Textures[assetId];
// }
// else if (Assets.ContainsKey(assetId))
// {
// asset = Assets[assetId];
// }
// return asset;
//}
private bool TryGetCachedAsset(LLUUID assetId, out AssetBase asset)
{ {
AssetBase asset = null; if (Textures.ContainsKey(assetId))
if (Textures.ContainsKey(assetID))
{ {
asset = Textures[assetID]; asset = Textures[assetId];
return true;
} }
else if (Assets.ContainsKey(assetID)) else if (Assets.ContainsKey(assetId))
{ {
asset = Assets[assetID]; asset = Assets[assetId];
} return true;
return asset;
} }
public void GetAsset(LLUUID assetID, AssetRequestCallback callback) asset = null;
{ return false;
AssetBase asset = null;
if (Textures.ContainsKey(assetID))
{
asset = Textures[assetID];
}
else if (Assets.ContainsKey(assetID))
{
asset = Assets[assetID];
} }
if (asset != null) public void GetAsset(LLUUID assetId, AssetRequestCallback callback)
{ {
callback(assetID, asset); AssetBase asset;
if (TryGetCachedAsset(assetId, out asset))
{
callback(assetId, asset);
} }
else else
{ {
NewAssetRequest req = new NewAssetRequest(assetID, callback); NewAssetRequest req = new NewAssetRequest(assetId, callback);
AssetRequestsList requestList; AssetRequestsList requestList;
lock (RequestLists) lock (RequestLists)
{ {
if (RequestLists.TryGetValue(assetID, out requestList)) if (RequestLists.TryGetValue(assetId, out requestList))
{ {
} }
else else
{ {
requestList = new AssetRequestsList(assetID); requestList = new AssetRequestsList(assetId);
RequestLists.Add(assetID, requestList); RequestLists.Add(assetId, requestList);
} }
} }
m_log.DebugFormat("[ASSETCACHE]: Added request for asset {0}", assetId);
requestList.Requests.Add(req); requestList.Requests.Add(req);
m_assetServer.RequestAsset(assetID, false); m_assetServer.RequestAsset(assetId, false);
} }
} }
@ -248,20 +260,17 @@ namespace OpenSim.Framework.Communications.Cache
int pollPeriod = 200; int pollPeriod = 200;
int maxPolls = 15; int maxPolls = 15;
AssetBase asset = GetCachedAsset(assetID); AssetBase asset;
if (asset != null)
{
return asset;
}
if (TryGetCachedAsset(assetID, out asset))
{
m_assetServer.RequestAsset(assetID, isTexture); m_assetServer.RequestAsset(assetID, isTexture);
do do
{ {
Thread.Sleep(pollPeriod); Thread.Sleep(pollPeriod);
asset = GetCachedAsset(assetID); if (TryGetCachedAsset(assetID, out asset))
if (asset != null)
{ {
return asset; return asset;
} }
@ -271,6 +280,11 @@ namespace OpenSim.Framework.Communications.Cache
return null; return null;
} }
else
{
return asset;
}
}
/// <summary> /// <summary>
/// Add an asset to both the persistent store and the cache. /// Add an asset to both the persistent store and the cache.
@ -337,26 +351,26 @@ namespace OpenSim.Framework.Communications.Cache
m_log.InfoFormat("[ASSETCACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result); m_log.InfoFormat("[ASSETCACHE]: Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result);
} }
public void DeleteAsset(LLUUID assetID)
{
// this.m_assetServer.DeleteAsset(assetID);
//Todo should delete it from memory too
}
public AssetBase CopyAsset(LLUUID assetID) public AssetBase CopyAsset(LLUUID assetID)
{ {
AssetBase asset = GetCachedAsset(assetID); AssetBase asset;
if (asset == null)
return null;
if (TryGetCachedAsset(assetID, out asset))
{
asset.FullID = LLUUID.Random(); // TODO: check for conflicts asset.FullID = LLUUID.Random(); // TODO: check for conflicts
AddAsset(asset); AddAsset(asset);
return asset; return asset;
} }
else
{
return null;
}
}
public void AssetReceived(AssetBase asset, bool IsTexture) public void AssetReceived(AssetBase asset, bool IsTexture)
{ {
m_log.InfoFormat("[ASSETCACHE]: Recieved {0} [{1}]", IsTexture ? "texture" : "asset", asset.FullID);
if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
{ {
//check if it is a texture or not //check if it is a texture or not
@ -366,18 +380,24 @@ namespace OpenSim.Framework.Communications.Cache
if (IsTexture) if (IsTexture)
{ {
//Console.WriteLine("asset received from asset server");
TextureImage image = new TextureImage(asset); TextureImage image = new TextureImage(asset);
if (!Textures.ContainsKey(image.FullID)) if (Textures.ContainsKey(image.FullID))
{
m_log.InfoFormat("[ASSETCACHE]: There's already an texture {0} in memory. Skipping.", asset.FullID);
}
else
{ {
Textures.Add(image.FullID, image); Textures.Add(image.FullID, image);
if (StatsManager.SimExtraStats != null) if (StatsManager.SimExtraStats != null)
{
StatsManager.SimExtraStats.AddTexture(image); StatsManager.SimExtraStats.AddTexture(image);
}
if (RequestedTextures.ContainsKey(image.FullID)) if (RequestedTextures.ContainsKey(image.FullID))
{ {
m_log.InfoFormat("[ASSETCACHE]: Moving {0} from RequestedTextures to TextureRequests", asset.FullID);
AssetRequest req = RequestedTextures[image.FullID]; AssetRequest req = RequestedTextures[image.FullID];
req.ImageInfo = image; req.ImageInfo = image;
@ -391,18 +411,27 @@ namespace OpenSim.Framework.Communications.Cache
else else
{ {
AssetInfo assetInf = new AssetInfo(asset); AssetInfo assetInf = new AssetInfo(asset);
if (!Assets.ContainsKey(assetInf.FullID)) if (Assets.ContainsKey(assetInf.FullID))
{
m_log.InfoFormat("[ASSETCACHE]: There's already an asset {0} in memory. Skipping.", asset.FullID);
}
else
{ {
Assets.Add(assetInf.FullID, assetInf); Assets.Add(assetInf.FullID, assetInf);
if (StatsManager.SimExtraStats != null) if (StatsManager.SimExtraStats != null)
{
StatsManager.SimExtraStats.AddAsset(assetInf); StatsManager.SimExtraStats.AddAsset(assetInf);
}
if (RequestedAssets.ContainsKey(assetInf.FullID)) if (RequestedAssets.ContainsKey(assetInf.FullID))
{ {
m_log.InfoFormat("[ASSETCACHE]: Moving {0} from RequestedAssets to AssetRequests", asset.FullID);
AssetRequest req = RequestedAssets[assetInf.FullID]; AssetRequest req = RequestedAssets[assetInf.FullID];
req.AssetInf = assetInf; req.AssetInf = assetInf;
req.NumPackets = CalculateNumPackets(assetInf.Data); req.NumPackets = CalculateNumPackets(assetInf.Data);
RequestedAssets.Remove(assetInf.FullID); RequestedAssets.Remove(assetInf.FullID);
AssetRequests.Add(req); AssetRequests.Add(req);
} }
@ -410,6 +439,8 @@ namespace OpenSim.Framework.Communications.Cache
} }
if (RequestLists.ContainsKey(asset.FullID)) if (RequestLists.ContainsKey(asset.FullID))
{
lock (RequestLists)
{ {
AssetRequestsList reqList = RequestLists[asset.FullID]; AssetRequestsList reqList = RequestLists[asset.FullID];
foreach (NewAssetRequest req in reqList.Requests) foreach (NewAssetRequest req in reqList.Requests)
@ -417,8 +448,6 @@ namespace OpenSim.Framework.Communications.Cache
req.Callback(asset.FullID, asset); req.Callback(asset.FullID, asset);
} }
lock (RequestLists)
{
RequestLists.Remove(asset.FullID); RequestLists.Remove(asset.FullID);
reqList.Requests.Clear(); reqList.Requests.Clear();
} }
@ -428,6 +457,8 @@ namespace OpenSim.Framework.Communications.Cache
public void AssetNotFound(LLUUID assetID) public void AssetNotFound(LLUUID assetID)
{ {
m_log.ErrorFormat("[ASSET CACHE]: Unhandled AssetNotFound for {0}", assetID);
//if (this.RequestedTextures.ContainsKey(assetID)) //if (this.RequestedTextures.ContainsKey(assetID))
//{ //{
// m_log.WarnFormat("[ASSET CACHE]: sending image not found for {0}", assetID); // m_log.WarnFormat("[ASSET CACHE]: sending image not found for {0}", assetID);

View File

@ -352,8 +352,6 @@ namespace OpenSim.Region.Environment.Scenes
sr.Close(); sr.Close();
UpdateParentIDs(); UpdateParentIDs();
ScheduleGroupForFullUpdate();
} }
private void AttachToBackup() private void AttachToBackup()

View File

@ -543,7 +543,6 @@ namespace OpenSim.Region.Environment.Scenes
set set
{ {
m_clickAction = value; m_clickAction = value;
ScheduleFullUpdate();
} }
} }

View File

@ -194,8 +194,9 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
rootPart.Velocity = receivedVelocity; rootPart.Velocity = receivedVelocity;
} }
obj.ScheduleGroupForFullUpdate();
} }
public void SavePrimsToXml2(string fileName) public void SavePrimsToXml2(string fileName)