From 09cd2ac4437e3905ba48b84e04559a0e606aa679 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 12 Oct 2009 20:46:19 +0100 Subject: Stop null values from being returned on database queries --- OpenSim/Data/MySQL/MySQLRegionData.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 3b561d1..f514076 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -151,7 +151,10 @@ namespace OpenSim.Data.MySQL DataTable schemaTable = result.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); + { + if (row["ColumnName"] != null) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } } foreach (string s in m_ColumnNames) -- cgit v1.1 From bf68dad64398f7bd4ae2992d345071d261c32e80 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 12 Oct 2009 23:21:32 +0100 Subject: 0004246: [Patch] FlotsamAssetCache deep scan & cache Thank you, mcortez. --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 307 ++++++++++++++++++--- bin/config-include/FlotsamCache.ini.example | 7 + 2 files changed, 277 insertions(+), 37 deletions(-) diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index b81ab41..4041b63 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -43,6 +43,7 @@ using Mono.Addins; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; @@ -54,7 +55,7 @@ using OpenSim.Services.Interfaces; namespace Flotsam.RegionModules.AssetCache { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache + public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService { private static readonly ILog m_log = LogManager.GetLogger( @@ -102,6 +103,11 @@ namespace Flotsam.RegionModules.AssetCache private System.Timers.Timer m_CachCleanTimer = new System.Timers.Timer(); + private IAssetService m_AssetService = null; + private List m_Scenes = new List(); + + private bool m_DeepScanBeforePurge = false; + public FlotsamAssetCache() { m_InvalidChars.AddRange(Path.GetInvalidPathChars()); @@ -121,6 +127,7 @@ namespace Flotsam.RegionModules.AssetCache public void Initialise(IConfigSource source) { IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) { @@ -195,7 +202,13 @@ namespace Flotsam.RegionModules.AssetCache m_CacheWarnAt = assetConfig.GetInt("CacheWarnAt", 30000); - + m_DeepScanBeforePurge = assetConfig.GetBoolean("DeepScanBeforePurge", false); + + MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache status", "fcache status", "Display cache status", HandleConsoleCommand); + MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache clear", "fcache clear [file] [memory]", "Remove all assets in the file and/or memory cache", HandleConsoleCommand); + MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache assets", "fcache assets", "Attempt a deep scan and cache of all assets in all scenes", HandleConsoleCommand); + MainConsole.Instance.Commands.AddCommand(this.Name, true, "fcache expire", "fcache expire ", "Purge cached assets older then the specified date/time", HandleConsoleCommand); + } } } @@ -213,16 +226,23 @@ namespace Flotsam.RegionModules.AssetCache if (m_Enabled) { scene.RegisterModuleInterface(this); + m_Scenes.Add(scene); - //scene.AddCommand(this, "flotsamcache", "", "Display a list of console commands for the Flotsam Asset Cache", HandleConsoleCommand); - scene.AddCommand(this, "flotsamcache counts", "flotsamcache counts", "Display the number of cached assets", HandleConsoleCommand); - scene.AddCommand(this, "flotsamcache clearmem", "flotsamcache clearmem", "Remove all assets cached in memory", HandleConsoleCommand); - scene.AddCommand(this, "flotsamcache clearfile", "flotsamcache clearfile", "Remove all assets cached on disk", HandleConsoleCommand); + if (m_AssetService == null) + { + m_AssetService = scene.RequestModuleInterface(); + + } } } public void RemoveRegion(Scene scene) { + if (m_Enabled) + { + scene.UnregisterModuleInterface(this); + m_Scenes.Remove(scene); + } } public void RegionLoaded(Scene scene) @@ -442,31 +462,47 @@ namespace Flotsam.RegionModules.AssetCache if (m_LogLevel >= 2) m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration.ToString()); + // Purge all files last accessed prior to this point + DateTime purgeLine = DateTime.Now - m_FileExpiration; + + // An optional deep scan at this point will ensure assets present in scenes, + // or referenced by objects in the scene, but not recently accessed + // are not purged. + if (m_DeepScanBeforePurge) + { + CacheScenes(); + } + foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) { - CleanExpiredFiles(dir); + CleanExpiredFiles(dir, purgeLine); } } /// - /// Recurses through specified directory checking for expired asset files and deletes them. Also removes empty directories. + /// Recurses through specified directory checking for asset files last + /// accessed prior to the specified purge line and deletes them. Also + /// removes empty tier directories. /// /// - private void CleanExpiredFiles(string dir) + private void CleanExpiredFiles(string dir, DateTime purgeLine) { + foreach (string file in Directory.GetFiles(dir)) { - if (DateTime.Now - File.GetLastAccessTime(file) > m_FileExpiration) + if (File.GetLastAccessTime(file) < purgeLine) { File.Delete(file); } } + // Recurse into lower tiers foreach (string subdir in Directory.GetDirectories(dir)) { - CleanExpiredFiles(subdir); + CleanExpiredFiles(subdir, purgeLine); } + // Check if a tier directory is empty, if so, delete it int dirSize = Directory.GetFiles(dir).Length + Directory.GetDirectories(dir).Length; if (dirSize == 0) { @@ -478,6 +514,11 @@ namespace Flotsam.RegionModules.AssetCache } } + /// + /// Determines the filename for an AssetID stored in the file cache + /// + /// + /// private string GetFileName(string id) { // Would it be faster to just hash the darn thing? @@ -496,14 +537,23 @@ namespace Flotsam.RegionModules.AssetCache return Path.Combine(path, id); } + /// + /// Writes a file to the file cache, creating any nessesary + /// tier directories along the way + /// + /// + /// private void WriteFileCache(string filename, AssetBase asset) { Stream stream = null; + // Make sure the target cache directory exists string directory = Path.GetDirectoryName(filename); + // Write file first to a temp name, so that it doesn't look // like it's already cached while it's still writing. string tempname = Path.Combine(directory, Path.GetRandomFileName()); + try { if (!Directory.Exists(directory)) @@ -563,6 +613,11 @@ namespace Flotsam.RegionModules.AssetCache } } + /// + /// Scan through the file cache, and return number of assets currently cached. + /// + /// + /// private int GetFileCacheCount(string dir) { int count = Directory.GetFiles(dir).Length; @@ -575,55 +630,180 @@ namespace Flotsam.RegionModules.AssetCache return count; } + /// + /// This notes the last time the Region had a deep asset scan performed on it. + /// + /// + private void StampRegionStatusFile(UUID RegionID) + { + string RegionCacheStatusFile = Path.Combine(m_CacheDirectory, "RegionStatus_" + RegionID.ToString() + ".fac"); + if (File.Exists(RegionCacheStatusFile)) + { + File.SetLastWriteTime(RegionCacheStatusFile, DateTime.Now); + } + else + { + File.WriteAllText(RegionCacheStatusFile, "Please do not delete this file unless you are manually clearing your Flotsam Asset Cache."); + } + } + + /// + /// Iterates through all Scenes, doing a deep scan through assets + /// to cache all assets present in the scene or referenced by assets + /// in the scene + /// + /// + private int CacheScenes() + { + UuidGatherer gatherer = new UuidGatherer(m_AssetService); + + Dictionary assets = new Dictionary(); + foreach (Scene s in m_Scenes) + { + StampRegionStatusFile(s.RegionInfo.RegionID); + + s.ForEachSOG(delegate(SceneObjectGroup e) + { + gatherer.GatherAssetUuids(e, assets); + } + ); + } + + foreach (UUID assetID in assets.Keys) + { + string filename = GetFileName(assetID.ToString()); + + if (File.Exists(filename)) + { + File.SetLastAccessTime(filename, DateTime.Now); + } + else + { + m_AssetService.Get(assetID.ToString()); + } + } + + return assets.Keys.Count; + } + + /// + /// Deletes all cache contents + /// + private void ClearFileCache() + { + foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) + { + try + { + Directory.Delete(dir, true); + } + catch (Exception e) + { + LogException(e); + } + } + + foreach (string file in Directory.GetFiles(m_CacheDirectory)) + { + try + { + File.Delete(file); + } + catch (Exception e) + { + LogException(e); + } + } + } + #region Console Commands private void HandleConsoleCommand(string module, string[] cmdparams) { - if (cmdparams.Length == 2) + if (cmdparams.Length >= 2) { string cmd = cmdparams[1]; switch (cmd) { - case "count": - case "counts": - m_log.InfoFormat("[FLOTSAM ASSET CACHE] Memory Cache : {0}", m_MemoryCache.Count); + case "status": + m_log.InfoFormat("[FLOTSAM ASSET CACHE] Memory Cache : {0} assets", m_MemoryCache.Count); int fileCount = GetFileCacheCount(m_CacheDirectory); - m_log.InfoFormat("[FLOTSAM ASSET CACHE] File Cache : {0}", fileCount); + m_log.InfoFormat("[FLOTSAM ASSET CACHE] File Cache : {0} assets", fileCount); - break; + foreach ( string s in Directory.GetFiles(m_CacheDirectory, "*.fac" ) ) + { + m_log.Info("[FLOTSAM ASSET CACHE] Deep Scans were performed on the following regions:"); + + string RegionID = s.Remove(0,s.IndexOf("_")).Replace(".fac",""); + DateTime RegionDeepScanTMStamp = File.GetLastWriteTime(s); + m_log.InfoFormat("[FLOTSAM ASSET CACHE] Region: {0}, {1}", RegionID, RegionDeepScanTMStamp.ToString("MM/dd/yyyy hh:mm:ss")); + } - case "clearmem": - m_MemoryCache.Clear(); - m_log.InfoFormat("[FLOTSAM ASSET CACHE] Memory Cache Cleared, there are now {0} items in the memory cache", m_MemoryCache.Count); break; - case "clearfile": - foreach (string dir in Directory.GetDirectories(m_CacheDirectory)) + case "clear": + if (cmdparams.Length < 3) { - try - { - Directory.Delete(dir, true); - } - catch (Exception e) - { - LogException(e); - } + m_log.Warn("[FLOTSAM ASSET CACHE] Please specify memory and/or file cache."); + break; } - - foreach (string file in Directory.GetFiles(m_CacheDirectory)) + foreach (string s in cmdparams) { - try + if (s.ToLower() == "memory") { - File.Delete(file); + m_MemoryCache.Clear(); + m_log.Info("[FLOTSAM ASSET CACHE] Memory cache cleared."); } - catch (Exception e) + else if (s.ToLower() == "file") { - LogException(e); + ClearFileCache(); + m_log.Info("[FLOTSAM ASSET CACHE] File cache cleared."); } } + break; + + + case "assets": + m_log.Info("[FLOTSAM ASSET CACHE] Caching all assets, in all scenes."); + + Util.FireAndForget(delegate { + int assetsCached = CacheScenes(); + m_log.InfoFormat("[FLOTSAM ASSET CACHE] Completed Scene Caching, {0} assets found.", assetsCached); + + }); break; + case "expire": + + + if (cmdparams.Length >= 3) + { + m_log.InfoFormat("[FLOTSAM ASSET CACHE] Invalid parameters for Expire, please specify a valid date & time", cmd); + break; + } + + string s_expirationDate = ""; + DateTime expirationDate; + + if (cmdparams.Length > 3) + { + s_expirationDate = string.Join(" ", cmdparams, 2, cmdparams.Length - 2); + } + else + { + s_expirationDate = cmdparams[2]; + } + + if (!DateTime.TryParse(s_expirationDate, out expirationDate)) + { + m_log.InfoFormat("[FLOTSAM ASSET CACHE] {0} is not a valid date & time", cmd); + break; + } + + CleanExpiredFiles(m_CacheDirectory, expirationDate); + + break; default: m_log.InfoFormat("[FLOTSAM ASSET CACHE] Unknown command {0}", cmd); break; @@ -631,13 +811,66 @@ namespace Flotsam.RegionModules.AssetCache } else if (cmdparams.Length == 1) { - m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache counts - Display the number of cached assets"); + m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache status - Display cache status"); m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearmem - Remove all assets cached in memory"); m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearfile - Remove all assets cached on disk"); + m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache cachescenes - Attempt a deep cache of all assets in all scenes"); + m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache - Purge assets older then the specified date & time"); } } #endregion + + #region IAssetService Members + + + public AssetMetadata GetMetadata(string id) + { + AssetBase asset = Get(id); + return asset.Metadata; + } + + public byte[] GetData(string id) + { + AssetBase asset = Get(id); + return asset.Data; + } + + public bool Get(string id, object sender, AssetRetrieved handler) + { + AssetBase asset = Get(id); + handler(id, sender, asset); + return true; + } + + public string Store(AssetBase asset) + { + if ((asset.FullID == null) || (asset.FullID == UUID.Zero)) + { + asset.FullID = UUID.Random(); + } + + Cache(asset); + + return asset.ID; + + } + + public bool UpdateContent(string id, byte[] data) + { + AssetBase asset = Get(id); + asset.Data = data; + Cache(asset); + return true; + } + + public bool Delete(string id) + { + Expire(id); + return true; + } + + #endregion } } \ No newline at end of file diff --git a/bin/config-include/FlotsamCache.ini.example b/bin/config-include/FlotsamCache.ini.example index abb3b9a..b50d7ec 100644 --- a/bin/config-include/FlotsamCache.ini.example +++ b/bin/config-include/FlotsamCache.ini.example @@ -50,3 +50,10 @@ ; Warning level for cache directory size ;CacheWarnAt = 30000 + + ; Perform a deep scan of all assets within all regions, looking for all assets + ; present or referenced. Mark all assets found that are already present in the + ; cache, and request all assets that are found that are not already cached (this + ; will cause those assets to be cached) + ; + ; DeepScanBeforePurge = false -- cgit v1.1 From c0beeb929e22509329781cdf85f7a5d90c4b0e36 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 12 Oct 2009 17:00:01 -0700 Subject: * Fixes http://opensimulator.org/mantis/view.php?id=4225 * Fixes http://opensimulator.org/mantis/view.php?id=3959 * Allows for viewing inventory textures outside home grid --- OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | 14 ++++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 21 +++-- .../Region/ClientStack/LindenUDP/LLImageManager.cs | 5 ++ .../ServiceConnectorsOut/Asset/HGAssetBroker.cs | 44 +++++++++- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 1 + .../Inventory/BaseInventoryConnector.cs | 3 + .../Inventory/HGInventoryBroker.cs | 2 + .../Framework/Scenes/Hypergrid/HGAssetMapper.cs | 98 ++++++++++------------ .../Scenes/Hypergrid/HGScene.Inventory.cs | 26 ++++++ OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 9 +- .../Inventory/HGInventoryServiceConnector.cs | 1 + 11 files changed, 162 insertions(+), 62 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 5877779..1bbe00f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs @@ -31,6 +31,7 @@ using OpenMetaverse; using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using log4net; using System.Reflection; @@ -54,6 +55,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP public UUID TextureID; public IJ2KDecoder J2KDecoder; public IAssetService AssetService; + public UUID AgentID; + public IHyperAssetService HyperAssets; public OpenJPEG.J2KLayerInfo[] Layers; public bool IsDecoded; public bool HasAsset; @@ -370,6 +373,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP UUID assetID = UUID.Zero; if (asset != null) assetID = asset.FullID; + else if (HyperAssets != null) + { + // Try the user's inventory, but only if it's different from the regions' + string userAssets = HyperAssets.GetUserAssetServer(AgentID); + if ((userAssets != string.Empty) && (userAssets != HyperAssets.GetSimAssetServer())) + { + m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id); + AssetService.Get(userAssets + "/" + id, this, AssetReceived); + return; + } + } AssetDataCallback(assetID, asset); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 84e705a..25eb5cd 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -43,6 +43,7 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Statistics; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using Timer=System.Timers.Timer; using AssetLandmark = OpenSim.Framework.AssetLandmark; @@ -117,6 +118,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected int m_packetMTU = 1400; protected IAssetService m_assetService; + #region Properties public UUID SecureSessionId { get { return m_secureSessionId; } } @@ -7013,7 +7015,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion //handlerTextureRequest = null; - for (int i = 0; i < imageRequest.RequestImage.Length; i++) { if (OnRequestTexture != null) @@ -7024,7 +7025,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP args.PacketNumber = imageRequest.RequestImage[i].Packet; args.Priority = imageRequest.RequestImage[i].DownloadPriority; args.requestSequence = imageRequest.Header.Sequence; - //handlerTextureRequest = OnRequestTexture; //if (handlerTextureRequest != null) @@ -7047,10 +7047,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Validate inventory transfers // Has to be done here, because AssetCache can't do it // - + UUID taskID = UUID.Zero; if (transfer.TransferInfo.SourceType == 3) { - UUID taskID = new UUID(transfer.TransferInfo.Params, 48); + taskID = new UUID(transfer.TransferInfo.Params, 48); UUID itemID = new UUID(transfer.TransferInfo.Params, 64); UUID requestID = new UUID(transfer.TransferInfo.Params, 80); if (!(((Scene)m_scene).Permissions.BypassPermissions())) @@ -7121,7 +7121,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP //m_assetCache.AddAssetRequest(this, transfer); - MakeAssetRequest(transfer); + MakeAssetRequest(transfer, taskID); /* RequestAsset = OnRequestAsset; if (RequestAsset != null) @@ -10330,7 +10330,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return String.Empty; } - public void MakeAssetRequest(TransferRequestPacket transferRequest) + public void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID) { UUID requestID = UUID.Zero; if (transferRequest.TransferInfo.SourceType == 2) @@ -10343,11 +10343,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP //inventory asset request requestID = new UUID(transferRequest.TransferInfo.Params, 80); //m_log.Debug("asset request " + requestID); + if (taskID == UUID.Zero) // Agent + if (m_scene is HGScene) + { + // We may need to fetch the asset from the user's asset server into the local asset server + HGAssetMapper mapper = ((HGScene)m_scene).AssetMapper; + mapper.Get(requestID, AgentId); + } } //check to see if asset is in local cache, if not we need to request it from asset server. //m_log.Debug("asset request " + requestID); - + m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 343f537..56d34e6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs @@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private C5.IntervalHeap m_priorityQueue = new C5.IntervalHeap(10, new J2KImageComparer()); private object m_syncRoot = new object(); + private IHyperAssetService m_hyperAssets; + public LLClientView Client { get { return m_client; } } public AssetBase MissingImage { get { return m_missingImage; } } @@ -74,6 +76,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); m_j2kDecodeModule = pJ2kDecodeModule; + m_hyperAssets = client.Scene.RequestModuleInterface(); } /// @@ -146,6 +149,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP imgrequest = new J2KImage(this); imgrequest.J2KDecoder = m_j2kDecodeModule; imgrequest.AssetService = m_assetCache; + imgrequest.AgentID = m_client.AgentId; + imgrequest.HyperAssets = m_hyperAssets; imgrequest.DiscardLevel = newRequest.DiscardLevel; imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); imgrequest.Priority = newRequest.Priority; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 7b4e374..0aa753d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; using System.Reflection; using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; using OpenSim.Server.Base; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -40,7 +41,7 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset { public class HGAssetBroker : - ISharedRegionModule, IAssetService + ISharedRegionModule, IAssetService, IHyperAssetService { private static readonly ILog m_log = LogManager.GetLogger( @@ -50,6 +51,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset private IAssetService m_GridService; private IAssetService m_HGService; + private Scene m_aScene; + private string m_LocalAssetServiceURI; + private bool m_Enabled = false; public Type ReplaceableInterface @@ -114,6 +118,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset return; } + m_LocalAssetServiceURI = assetConfig.GetString("AssetServerURI", string.Empty); + if (m_LocalAssetServiceURI == string.Empty) + { + IConfig netConfig = source.Configs["Network"]; + m_LocalAssetServiceURI = netConfig.GetString("asset_server_url", string.Empty); + } + + if (m_LocalAssetServiceURI != string.Empty) + m_LocalAssetServiceURI = m_LocalAssetServiceURI.Trim('/'); + m_Enabled = true; m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled"); } @@ -132,8 +146,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset { if (!m_Enabled) return; + + m_aScene = scene; scene.RegisterModuleInterface(this); + scene.RegisterModuleInterface(this); } public void RemoveRegion(Scene scene) @@ -344,5 +361,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset else return m_GridService.Delete(id); } + + #region IHyperAssetService + + public string GetUserAssetServer(UUID userID) + { + CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); + if ((uinfo != null) && (uinfo.UserProfile != null)) + { + if ((uinfo.UserProfile.UserAssetURI == string.Empty) || (uinfo.UserProfile.UserAssetURI == "")) + return m_LocalAssetServiceURI; + return uinfo.UserProfile.UserAssetURI.Trim('/'); + } + else + { + // we don't know anyting about this user + return string.Empty; + } + } + + public string GetSimAssetServer() + { + return m_LocalAssetServiceURI; + } + + #endregion } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 148331b..1422add 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -759,6 +759,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } + protected bool IsLocalRegion(ulong handle) { return m_LocalScenes.ContainsKey(handle); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs index bd32f3b..811569f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs @@ -159,6 +159,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory /// true if the item was successfully added public bool AddItem(InventoryItemBase item) { + if (item == null) + return false; + if (item.Folder == UUID.Zero) { InventoryFolderBase f = GetFolderForType(item.Owner, (AssetType)item.AssetType); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index fd1a759..f073f32 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -386,7 +386,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return false; if (IsLocalGridUser(item.Owner)) + { return m_GridService.AddItem(item); + } else { UUID sessionID = GetSessionID(item.Owner); diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index b6fa41d..244ac3b 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Clients; using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Region.Framework.Interfaces; using OpenSim.Services.Interfaces; //using HyperGrid.Framework; @@ -52,13 +53,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid private Scene m_scene; - private IHyperlinkService m_hyper; - IHyperlinkService HyperlinkService + private IHyperAssetService m_hyper; + IHyperAssetService HyperlinkAssets { get { if (m_hyper == null) - m_hyper = m_scene.RequestModuleInterface(); + m_hyper = m_scene.RequestModuleInterface(); return m_hyper; } } @@ -99,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid if (asset != null) { - m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); + m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url); return asset; } return null; @@ -129,6 +130,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid } m_scene.AssetService.Store(asset1); + m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); } return true; } @@ -167,34 +169,32 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid public void Get(UUID assetID, UUID ownerID) { - if (!HyperlinkService.IsLocalUser(ownerID)) + // Get the item from the remote asset server onto the local AssetCache + // and place an entry in m_assetMap + + string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID); + if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer())) { - // Get the item from the remote asset server onto the local AssetCache - // and place an entry in m_assetMap + m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL); + AssetBase asset = FetchAsset(userAssetURL, assetID); - string userAssetURL = UserAssetURL(ownerID); - if (userAssetURL != null) + if (asset != null) { - m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); - AssetBase asset = FetchAsset(userAssetURL, assetID); + // OK, now fetch the inside. + Dictionary ids = new Dictionary(); + HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); + uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); + foreach (UUID uuid in ids.Keys) + FetchAsset(userAssetURL, uuid); + + m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL); - if (asset != null) - { - m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); - - // OK, now fetch the inside. - Dictionary ids = new Dictionary(); - HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); - uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); - foreach (UUID uuid in ids.Keys) - FetchAsset(userAssetURL, uuid); - } - else - m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); } else - m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); + m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); } + else + m_log.Debug("[HGScene]: user's asset server is the local region's asset server"); } //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) @@ -225,44 +225,38 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid public void Post(UUID assetID, UUID ownerID) { - if (!HyperlinkService.IsLocalUser(ownerID)) - { // Post the item from the local AssetCache onto the remote asset server // and place an entry in m_assetMap - string userAssetURL = UserAssetURL(ownerID); - if (userAssetURL != null) + string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID); + if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer())) + { + m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); + AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); + if (asset != null) { - m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); - AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); - if (asset != null) + Dictionary ids = new Dictionary(); + HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); + uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); + foreach (UUID uuid in ids.Keys) { - Dictionary ids = new Dictionary(); - HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); - uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); - foreach (UUID uuid in ids.Keys) - { - asset = m_scene.AssetService.Get(uuid.ToString()); - if (asset != null) - m_log.DebugFormat("[HGScene]: Posting {0} {1}", asset.Type.ToString(), asset.Name); - else - m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid); + asset = m_scene.AssetService.Get(uuid.ToString()); + if (asset == null) + m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid); + else PostAsset(userAssetURL, asset); - } + } - if (ids.Count > 0) // maybe it succeeded... - m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL); - else - m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL); + // maybe all pieces got there... + m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); - } - else - m_log.Debug("[HGScene]: Something wrong with asset, it could not be found"); } else - m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); - + m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID); } + else + m_log.Debug("[HGScene]: user's asset server is local region's asset server"); + } #endregion diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs index 8fe3565..6f7f34f 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs @@ -32,6 +32,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; +using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.Framework.Scenes.Hypergrid { @@ -41,6 +42,21 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private HGAssetMapper m_assMapper; + public HGAssetMapper AssetMapper + { + get { return m_assMapper; } + } + + private IHyperAssetService m_hyper; + private IHyperAssetService HyperAssets + { + get + { + if (m_hyper == null) + m_hyper = RequestModuleInterface(); + return m_hyper; + } + } #endregion @@ -140,6 +156,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid } + protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) + { + string userAssetServer = HyperAssets.GetUserAssetServer(sender); + if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) + m_assMapper.Get(item.AssetID, sender); + + userAssetServer = HyperAssets.GetUserAssetServer(receiver); + if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) + m_assMapper.Post(item.AssetID, receiver); + } #endregion diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1917228..0cb5682 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -408,7 +408,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual InventoryItemBase GiveInventoryItem( UUID recipient, UUID senderId, UUID itemId, UUID recipientFolderId) { - Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); + //Console.WriteLine("Scene.Inventory.cs: GiveInventoryItem"); InventoryItemBase item = new InventoryItemBase(itemId, senderId); item = InventoryService.GetItem(item); @@ -472,7 +472,8 @@ namespace OpenSim.Region.Framework.Scenes itemCopy.SalePrice = item.SalePrice; itemCopy.SaleType = item.SaleType; - InventoryService.AddItem(itemCopy); + if (InventoryService.AddItem(itemCopy)) + TransferInventoryAssets(itemCopy, senderId, recipient); if (!Permissions.BypassPermissions()) { @@ -494,6 +495,10 @@ namespace OpenSim.Region.Framework.Scenes } + protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) + { + } + /// /// Give an entire inventory folder from one user to another. The entire contents (including all descendent /// folders) is given. diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 1004fb9..9878855 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs @@ -299,6 +299,7 @@ namespace OpenSim.Services.Connectors.Inventory if (StringToUrlAndUserID(id, out url, out userID)) { + //m_log.DebugFormat("[HGInventory CONNECTOR]: calling {0}", url); ISessionAuthInventoryService connector = GetConnector(url); return connector.QueryItem(userID, item, sessionID); } -- cgit v1.1 From 0cfbdf3894756654465c0a2e1b8e796fcdb37baa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 12 Oct 2009 17:01:03 -0700 Subject: Added this one file for the previous commit to work. --- .../Region/Framework/Interfaces/IHyperService.cs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 OpenSim/Region/Framework/Interfaces/IHyperService.cs diff --git a/OpenSim/Region/Framework/Interfaces/IHyperService.cs b/OpenSim/Region/Framework/Interfaces/IHyperService.cs new file mode 100644 index 0000000..51ea28a --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IHyperService.cs @@ -0,0 +1,37 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using OpenMetaverse; + +namespace OpenSim.Region.Framework.Interfaces +{ + public interface IHyperAssetService + { + string GetUserAssetServer(UUID userID); + string GetSimAssetServer(); + } +} -- cgit v1.1 From 63ed605eba7d4655bbbf956cef0d6e6b02b4a64e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 12 Oct 2009 17:36:13 -0700 Subject: Stop the recurring texture requests for textures that truly don't exist. --- OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 1bbe00f..bb98f24 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs @@ -373,14 +373,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP UUID assetID = UUID.Zero; if (asset != null) assetID = asset.FullID; - else if (HyperAssets != null) + else if ((HyperAssets != null) && (sender != HyperAssets)) { // Try the user's inventory, but only if it's different from the regions' string userAssets = HyperAssets.GetUserAssetServer(AgentID); if ((userAssets != string.Empty) && (userAssets != HyperAssets.GetSimAssetServer())) { m_log.DebugFormat("[J2KIMAGE]: texture {0} not found in local asset storage. Trying user's storage.", id); - AssetService.Get(userAssets + "/" + id, this, AssetReceived); + AssetService.Get(userAssets + "/" + id, HyperAssets, AssetReceived); return; } } -- cgit v1.1 From f3d2192cd486cf32517e6c4549a3a691422a5f88 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 12 Oct 2009 18:30:06 -0700 Subject: Better handling of missing assets. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 25eb5cd..ad92494 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -117,6 +117,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected int m_avatarTerseUpdatesPerPacket = 5; protected int m_packetMTU = 1400; protected IAssetService m_assetService; + private IHyperAssetService m_hyperAssets; #region Properties @@ -172,6 +173,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_scene = scene; m_assetService = m_scene.RequestModuleInterface(); + m_hyperAssets = m_scene.RequestModuleInterface(); m_GroupsModule = scene.RequestModuleInterface(); m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface()); m_channelVersion = Utils.StringToBytes(scene.GetSimulatorVersion()); @@ -10342,14 +10344,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP { //inventory asset request requestID = new UUID(transferRequest.TransferInfo.Params, 80); - //m_log.Debug("asset request " + requestID); - if (taskID == UUID.Zero) // Agent - if (m_scene is HGScene) - { - // We may need to fetch the asset from the user's asset server into the local asset server - HGAssetMapper mapper = ((HGScene)m_scene).AssetMapper; - mapper.Get(requestID, AgentId); - } + //m_log.Debug("[XXX] inventory asset request " + requestID); + //if (taskID == UUID.Zero) // Agent + // if (m_scene is HGScene) + // { + // m_log.Debug("[XXX] hg asset request " + requestID); + // // We may need to fetch the asset from the user's asset server into the local asset server + // HGAssetMapper mapper = ((HGScene)m_scene).AssetMapper; + // mapper.Get(requestID, AgentId); + // } } //check to see if asset is in local cache, if not we need to request it from asset server. @@ -10378,10 +10381,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP //m_log.Debug("asset request " + requestID); } - // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. if (null == asset) { + // Try the user's inventory, but only if it's different from the regions' + string userAssets = m_hyperAssets.GetUserAssetServer(AgentId); + if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer())) + { + m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id); + transferRequest.TransferInfo.SourceType = 9999; // marker + m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived); + return; + } + //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID); + + // FIXME: We never tell the client about assets which do not exist when requested by this transfer mechanism, which can't be right. return; } -- cgit v1.1 From e3d5beebfb44aee8a9bd30526be8d4e65adf632b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 13 Oct 2009 06:39:11 -0700 Subject: Better handling of missing assets. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index ad92494..d64f655 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -10368,12 +10368,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP UUID requestID = UUID.Zero; byte source = 2; - if (transferRequest.TransferInfo.SourceType == 2) + if ((transferRequest.TransferInfo.SourceType == 2) || (transferRequest.TransferInfo.SourceType == 2222)) { //direct asset request requestID = new UUID(transferRequest.TransferInfo.Params, 0); } - else if (transferRequest.TransferInfo.SourceType == 3) + else if ((transferRequest.TransferInfo.SourceType == 3) || (transferRequest.TransferInfo.SourceType == 3333)) { //inventory asset request requestID = new UUID(transferRequest.TransferInfo.Params, 80); @@ -10383,14 +10383,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (null == asset) { - // Try the user's inventory, but only if it's different from the regions' - string userAssets = m_hyperAssets.GetUserAssetServer(AgentId); - if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer())) + if ((m_hyperAssets != null) && (transferRequest.TransferInfo.SourceType < 2000)) { - m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id); - transferRequest.TransferInfo.SourceType = 9999; // marker - m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived); - return; + // Try the user's inventory, but only if it's different from the regions' + string userAssets = m_hyperAssets.GetUserAssetServer(AgentId); + if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer())) + { + m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id); + if (transferRequest.TransferInfo.SourceType == 2) + transferRequest.TransferInfo.SourceType = 2222; // marker + else if (transferRequest.TransferInfo.SourceType == 3) + transferRequest.TransferInfo.SourceType = 3333; // marker + + m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived); + return; + } } //m_log.DebugFormat("[ASSET CACHE]: Asset transfer request for asset which is {0} already known to be missing. Dropping", requestID); -- cgit v1.1 From 31a61bbeec5aae6b679ffa53e2966420e774f301 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Tue, 13 Oct 2009 22:03:00 -0400 Subject: * Fixes some prim crossings on megaregions with regions beyond the 512m mark * There's a slight chance that this could cause a problem with regular prim crossings.. but hopefully not. Revert if it does. --- .../CoreModules/World/Land/RegionCombinerModule.cs | 10 +- OpenSim/Region/Framework/Scenes/Scene.cs | 114 +++++++++++++++++---- 2 files changed, 99 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs index 05d19a2..6499915 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs @@ -343,7 +343,9 @@ namespace OpenSim.Region.CoreModules.World.Land lock (scene.WestBorders) { - scene.WestBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport West + + + scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West // Trigger auto teleport to root region scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; @@ -410,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.Land conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; lock (scene.SouthBorders) { - scene.SouthBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport south + scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; } @@ -481,7 +483,7 @@ namespace OpenSim.Region.CoreModules.World.Land lock (scene.SouthBorders) { - scene.SouthBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport south + scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; } @@ -503,7 +505,7 @@ namespace OpenSim.Region.CoreModules.World.Land lock (scene.WestBorders) { - scene.WestBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport West + scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 949cf19..0f351ce 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1780,36 +1780,86 @@ namespace OpenSim.Region.Framework.Scenes Vector3 pos = attemptedPosition; + int changeX = 1; + int changeY = 1; + if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) { if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) { - //Border crossedBorderx = GetCrossedBorder(attemptedPosition,Cardinals.W); - //Border crossedBordery = GetCrossedBorder(attemptedPosition, Cardinals.S); + + Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + + Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) - pos.X = ((pos.X + Constants.RegionSize)); - pos.Y = ((pos.Y + Constants.RegionSize)); + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + + newRegionHandle - = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), - (uint)((thisy - 1) * Constants.RegionSize)); + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + (uint)((thisy - changeY) * Constants.RegionSize)); // x - 1 // y - 1 } else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) { - pos.X = ((pos.X + Constants.RegionSize)); - pos.Y = ((pos.Y - Constants.RegionSize)); + Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + + + Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + newRegionHandle - = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), - (uint)((thisy + 1) * Constants.RegionSize)); + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + (uint)((thisy + changeY) * Constants.RegionSize)); // x - 1 // y + 1 } else { - pos.X = ((pos.X + Constants.RegionSize)); + Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + newRegionHandle - = Util.UIntsToLong((uint) ((thisx - 1)*Constants.RegionSize), + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), (uint) (thisy*Constants.RegionSize)); // x - 1 } @@ -1818,11 +1868,23 @@ namespace OpenSim.Region.Framework.Scenes { if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) { + pos.X = ((pos.X - Constants.RegionSize)); - pos.Y = ((pos.Y + Constants.RegionSize)); + Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + newRegionHandle - = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), - (uint)((thisy - 1) * Constants.RegionSize)); + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + (uint)((thisy - changeY) * Constants.RegionSize)); // x + 1 // y - 1 } @@ -1831,8 +1893,8 @@ namespace OpenSim.Region.Framework.Scenes pos.X = ((pos.X - Constants.RegionSize)); pos.Y = ((pos.Y - Constants.RegionSize)); newRegionHandle - = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), - (uint)((thisy + 1) * Constants.RegionSize)); + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + (uint)((thisy + changeY) * Constants.RegionSize)); // x + 1 // y + 1 } @@ -1840,16 +1902,26 @@ namespace OpenSim.Region.Framework.Scenes { pos.X = ((pos.X - Constants.RegionSize)); newRegionHandle - = Util.UIntsToLong((uint) ((thisx + 1)*Constants.RegionSize), + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), (uint) (thisy*Constants.RegionSize)); // x + 1 } } else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) { - pos.Y = ((pos.Y + Constants.RegionSize)); + Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + newRegionHandle - = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); + = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); // y - 1 } else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) @@ -1857,7 +1929,7 @@ namespace OpenSim.Region.Framework.Scenes pos.Y = ((pos.Y - Constants.RegionSize)); newRegionHandle - = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); + = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); // y + 1 } -- cgit v1.1 From db4cdc09614abc1c35a242f4c882b2e3285f0206 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 14 Oct 2009 04:18:59 +0100 Subject: Set the estate owner to be the master avatar if it's not set. --- OpenSim/Services/Interfaces/IGridService.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 14560b1..e69e4cd 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs @@ -200,6 +200,12 @@ namespace OpenSim.Services.Interfaces Maturity = ConvertFrom.RegionSettings.Maturity; RegionSecret = ConvertFrom.regionSecret; EstateOwner = ConvertFrom.EstateSettings.EstateOwner; + if (EstateOwner == UUID.Zero) + { + EstateOwner = ConvertFrom.MasterAvatarAssignedUUID; + ConvertFrom.EstateSettings.EstateOwner = EstateOwner; + ConvertFrom.EstateSettings.Save(); + } } public GridRegion(GridRegion ConvertFrom) -- cgit v1.1