From e1782bc2490980688e076f25baed8b75af67b450 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 4 Jul 2008 18:36:12 +0000 Subject: * refactor: break out archiver's combined sync-async asset request routine ready for analysis of inventory item types other than objects --- .../Archiver/ArchiveWriteRequestPreparation.cs | 62 +++++++++++++--------- 1 file changed, 37 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/World') diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs index fd77cd0..2e48095 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -82,6 +82,35 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver Monitor.Pulse(this); } } + + /// + /// Get an asset synchronously, potentially using an asynchronous callback. If the + /// asynchronous callback is used, we will wait for it to complete. + /// + /// + /// + protected AssetBase GetAsset(LLUUID uuid) + { + m_waitingForObjectAsset = true; + m_scene.AssetCache.GetAsset(uuid, AssetRequestCallback, true); + + // The asset cache callback can either + // + // 1. Complete on the same thread (if the asset is already in the cache) or + // 2. Come in via a different thread (if we need to go fetch it). + // + // The code below handles both these alternatives. + lock (this) + { + if (m_waitingForObjectAsset) + { + Monitor.Wait(this); + m_waitingForObjectAsset = false; + } + } + + return m_requestedObjectAsset; + } /// /// Get all the asset uuids associated with a given object. This includes both those directly associated with @@ -116,44 +145,27 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver assetUuids[texture.TextureID] = 1; } } - foreach (TaskInventoryItem tii in part.TaskInventory.Values) { if (!assetUuids.ContainsKey(tii.AssetID)) { assetUuids[tii.AssetID] = 1; - if (tii.Type != (int)InventoryType.Object) + if ((int)InventoryType.Object == tii.Type) { - m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tii.AssetID, part.UUID); - } - else - { - m_waitingForObjectAsset = true; - m_scene.AssetCache.GetAsset(tii.AssetID, AssetRequestCallback, true); - - // The asset cache callback can either - // - // 1. Complete on the same thread (if the asset is already in the cache) or - // 2. Come in via a different thread (if we need to go fetch it). - // - // The code below handles both these alternatives. - lock (this) - { - if (m_waitingForObjectAsset) - { - Monitor.Wait(this); - m_waitingForObjectAsset = false; - } - } + AssetBase objectAsset = GetAsset(tii.AssetID); - if (null != m_requestedObjectAsset) + if (null != objectAsset) { - string xml = Helpers.FieldToUTF8String(m_requestedObjectAsset.Data); + string xml = Helpers.FieldToUTF8String(objectAsset.Data); SceneObjectGroup sog = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, xml); GetSceneObjectAssetUuids(sog, assetUuids); } } + else + { + m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tii.AssetID, part.UUID); + } } } } -- cgit v1.1