From cf58c0ab082fa543e01f221addec58de5e0c575f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Aug 2009 12:01:21 +0100 Subject: minor: remove some commented out iar test code --- .../Inventory/Archiver/Tests/InventoryArchiverTests.cs | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index d51ed40..8f1ba5c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -102,19 +102,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Monitor.Wait(this, 60000); } - /* - cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); - CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId, InventoryReceived); - userInfo.FetchInventory(); - for (int i = 0 ; i < 50 ; i++) - { - if (userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); - } - Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); - */ - // Create asset SceneObjectGroup object1; SceneObjectPart part1; -- cgit v1.1 From d649194be310bf267675ac3cd9f9fce302cc3798 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Aug 2009 12:52:40 +0100 Subject: minor: formatting and comments --- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 3 ++- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 8f1ba5c..47a325b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -135,7 +135,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests item1.AssetID = asset1.FullID; item1.ID = item1Id; //userInfo.RootFolder.FindFolderByPath("Objects").ID; - InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); + //InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); + InventoryFolderBase rootFolder = scene.InventoryService.GetRootFolder(userId); item1.Folder = objsFolder.ID; scene.AddInventoryItem(userId, item1); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 3301536..650fc7e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -535,7 +535,9 @@ namespace OpenSim.Region.Framework.Scenes } UUID newFolderId = UUID.Random(); - InventoryFolderBase newFolder = new InventoryFolderBase(newFolderId, folder.Name, recipientId, folder.Type, recipientParentFolderId, folder.Version); + InventoryFolderBase newFolder + = new InventoryFolderBase( + newFolderId, folder.Name, recipientId, folder.Type, recipientParentFolderId, folder.Version); InventoryService.AddFolder(newFolder); // Give all the subfolders -- cgit v1.1 From 7f8df4242ba1564f6c758c88a67e1454e2a7a116 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Aug 2009 12:58:10 +0100 Subject: Correct build break --- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 47a325b..907c8f4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -135,8 +135,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests item1.AssetID = asset1.FullID; item1.ID = item1Id; //userInfo.RootFolder.FindFolderByPath("Objects").ID; - //InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); - InventoryFolderBase rootFolder = scene.InventoryService.GetRootFolder(userId); + InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); + //InventoryFolderBase rootFolder = scene.InventoryService.GetRootFolder(userId); item1.Folder = objsFolder.ID; scene.AddInventoryItem(userId, item1); -- cgit v1.1 From 7ff4c2e50b3df8ea82dc8a27f3b68657fe29226b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Aug 2009 17:07:17 +0100 Subject: Pull out distinct cache system folders and drop cache methods in InventoryCache --- .../Archiver/Tests/InventoryArchiverTests.cs | 14 ++++++- .../Inventory/InventoryCache.cs | 47 ++++++++++++++++------ 2 files changed, 46 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 907c8f4..1696d82 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Setup; @@ -102,6 +103,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Monitor.Wait(this, 60000); } + Console.WriteLine("here"); + // Create asset SceneObjectGroup object1; SceneObjectPart part1; @@ -135,8 +138,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests item1.AssetID = asset1.FullID; item1.ID = item1Id; //userInfo.RootFolder.FindFolderByPath("Objects").ID; - InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); - //InventoryFolderBase rootFolder = scene.InventoryService.GetRootFolder(userId); + //InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); + Console.WriteLine("here2"); + IInventoryService inventoryService = scene.InventoryService; + InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); + InventoryCollection rootContents = inventoryService.GetFolderContent(userId, rootFolder.ID); + InventoryFolderBase objsFolder = null; + foreach (InventoryFolderBase folder in rootContents.Folders) + if (folder.Name == "Objects") + objsFolder = folder; item1.Folder = objsFolder.ID; scene.AddInventoryItem(userId, item1); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index c8f04a5..73ffc5e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -88,13 +88,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } // If not, go get them and place them in the cache - Dictionary folders = m_Connector.GetSystemFolders(presence.UUID); + Dictionary folders = CacheSystemFolders(presence.UUID); m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}", presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count); - - if (folders.Count > 0) - lock (m_InventoryCache) - m_InventoryCache.Add(presence.UUID, folders); } void OnClientClosed(UUID clientID, Scene scene) @@ -113,26 +109,51 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } - // Drop system folders + m_log.DebugFormat( + "[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders", + scene.RegionInfo.RegionName, clientID); + DropCachedSystemFolders(clientID); + } + } + + /// + /// Cache a user's 'system' folders. + /// + /// + /// Folders cached + protected Dictionary CacheSystemFolders(UUID userID) + { + // If not, go get them and place them in the cache + Dictionary folders = m_Connector.GetSystemFolders(userID); + + if (folders.Count > 0) lock (m_InventoryCache) - if (m_InventoryCache.ContainsKey(clientID)) - { - m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders", - scene.RegionInfo.RegionName, clientID); + m_InventoryCache.Add(userID, folders); - m_InventoryCache.Remove(clientID); - } - } + return folders; } + /// + /// Drop a user's cached 'system' folders + /// + /// + protected void DropCachedSystemFolders(UUID userID) + { + // Drop system folders + lock (m_InventoryCache) + if (m_InventoryCache.ContainsKey(userID)) + m_InventoryCache.Remove(userID); + } public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) { Dictionary folders = null; + lock (m_InventoryCache) { m_InventoryCache.TryGetValue(userID, out folders); } + if ((folders != null) && folders.ContainsKey(type)) { return folders[type]; -- cgit v1.1 From 18c5dc0953a1c142fd8c13658f6183d5b3c3482a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Aug 2009 17:19:45 +0100 Subject: Try to cache system folders if they aren't already there when one is requested This operation can be performed legitimately on standalones without a logged in user --- .../ServiceConnectorsOut/Inventory/InventoryCache.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs index 73ffc5e..3c3534f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs @@ -145,6 +145,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory m_InventoryCache.Remove(userID); } + /// + /// Get the system folder for a particular asset type + /// + /// + /// + /// public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) { Dictionary folders = null; @@ -152,6 +158,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory lock (m_InventoryCache) { m_InventoryCache.TryGetValue(userID, out folders); + + // In some situations (such as non-secured standalones), system folders can be requested without + // the user being logged in. So we need to try caching them here if we don't already have them. + if (null == folders) + CacheSystemFolders(userID); + + m_InventoryCache.TryGetValue(userID, out folders); } if ((folders != null) && folders.ContainsKey(type)) -- cgit v1.1 From 33004b613db30b0b1c3be9baaea1efacfc4826c5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 28 Aug 2009 18:12:30 +0100 Subject: Standardize FlotsamAssetCache header Add mcortez to CONTRIBUTORS Other minor tidy of CONTRIBUTORS --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index c91b63e..53b8ebc 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -1,29 +1,29 @@ /* -Copyright (c) Contributors, http://osflotsam.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 Flotsam 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. */ + * 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. + */ // Uncomment to make asset Get requests for existing // #define WAIT_ON_INPROGRESS_REQUESTS -- cgit v1.1 From 3d6edc04a309757ce025e74aaf7168ef759a2ef3 Mon Sep 17 00:00:00 2001 From: Arthur Valadares Date: Fri, 28 Aug 2009 17:48:03 -0300 Subject: Implements osDrawPolygon, similar to already implemented osDrawFilledPolygon --- .../Scripting/VectorRender/VectorRenderModule.cs | 6 ++++++ .../Shared/Api/Implementation/OSSL_Api.cs | 19 +++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 4 files changed, 31 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index e577fbe..e83b1a8 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -484,6 +484,12 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender GetParams(partsDelimiter, ref nextLine, 11, ref points); graph.FillPolygon(myBrush, points); } + else if (nextLine.StartsWith("Polygon")) + { + PointF[] points = null; + GetParams(partsDelimiter, ref nextLine, 7, ref points); + graph.DrawPolygon(drawPen, points); + } else if (nextLine.StartsWith("Ellipse")) { float x = 0; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b1c357c..0de5c9b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -852,6 +852,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return drawList; } + public string osDrawPolygon(string drawList, LSL_List x, LSL_List y) + { + CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon"); + + m_host.AddScriptLPS(1); + + if (x.Length != y.Length || x.Length < 3) + { + return ""; + } + drawList += "Polygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0); + for (int i = 1; i < x.Length; i++) + { + drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i); + } + drawList += "; "; + return drawList; + } + public string osSetFontSize(string drawList, int fontSize) { CheckThreatLevel(ThreatLevel.None, "osSetFontSize"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 2365bee..b129b39 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -97,6 +97,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osDrawEllipse(string drawList, int width, int height); string osDrawRectangle(string drawList, int width, int height); string osDrawFilledRectangle(string drawList, int width, int height); + string osDrawPolygon(string drawList, LSL_List x, LSL_List y); string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y); string osSetFontSize(string drawList, int fontSize); string osSetPenSize(string drawList, int penSize); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index f877acb..45492dd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -267,6 +267,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height); } + public string osDrawPolygon(string drawList, LSL_List x, LSL_List y) + { + return m_OSSL_Functions.osDrawPolygon(drawList, x, y); + } + public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y) { return m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y); -- cgit v1.1 From 22a0dff22624984080bebc03ff63025fc213eeff Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 28 Aug 2009 23:28:32 +0100 Subject: Modify CAPS inventory code. Currently this is not executed --- OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index d3e414f..c816790 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -472,7 +472,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// null if the inventory look up failed - public List HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, + public InventoryCollection HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { // m_log.DebugFormat( @@ -487,11 +487,15 @@ namespace OpenSim.Region.Framework.Scenes InventoryFolderImpl fold; if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) { - return fold.RequestListOfItems(); + InventoryCollection ret = new InventoryCollection(); + ret.Folders = new List(); + ret.Items = fold.RequestListOfItems(); + + return ret; } InventoryCollection contents = InventoryService.GetFolderContent(agentID, folderID); - return contents.Items; + return contents; } -- cgit v1.1 From 976cf4284bdbef14553c2e164cb67d25bd2b9076 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 29 Aug 2009 03:26:44 +0100 Subject: Fix up WebFetchInventoryDescendents to really return all data needed, especially the folder version and the subfolders. Fixes inventory search hang and folders not loading. --- .../Region/Framework/Scenes/Scene.PacketHandlers.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index c816790..55b100b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -473,7 +473,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// null if the inventory look up failed public InventoryCollection HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, - bool fetchFolders, bool fetchItems, int sortOrder) + bool fetchFolders, bool fetchItems, int sortOrder, out int version) { // m_log.DebugFormat( // "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", @@ -487,6 +487,7 @@ namespace OpenSim.Region.Framework.Scenes InventoryFolderImpl fold; if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) { + version = 0; InventoryCollection ret = new InventoryCollection(); ret.Folders = new List(); ret.Items = fold.RequestListOfItems(); @@ -495,6 +496,21 @@ namespace OpenSim.Region.Framework.Scenes } InventoryCollection contents = InventoryService.GetFolderContent(agentID, folderID); + + if (folderID != UUID.Zero) + { + InventoryFolderBase containingFolder = new InventoryFolderBase(); + containingFolder.ID = folderID; + containingFolder.Owner = agentID; + containingFolder = InventoryService.GetFolder(containingFolder); + version = containingFolder.Version; + } + else + { + // Lost itemsm don't really need a version + version = 1; + } + return contents; } -- cgit v1.1 From 4b2e62fd3c347ec4d72762c19443e4a2765582f2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 29 Aug 2009 04:35:18 +0100 Subject: Make the j2kDecodeCache expire after 50 minutes (configurable). Alse allows setting the path for it. This commit introduces NEW DEFAULT BEHAVIOR. To retain the old behavior (eternal cache) you will need to change your OpenSim.ini and set the timeout to 0. --- .../Agent/TextureSender/J2KDecoderModule.cs | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 0d3cc23..00a247c 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -53,8 +53,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender /// private readonly Dictionary m_cacheddecode = new Dictionary(); private bool OpenJpegFail = false; - private readonly string CacheFolder = Util.dataDir() + "/j2kDecodeCache"; - private readonly J2KDecodeFileCache fCache; + private string CacheFolder = Util.dataDir() + "/j2kDecodeCache"; + private int CacheTimeout = 60; + private J2KDecodeFileCache fCache; /// /// List of client methods to notify of results of decode @@ -63,11 +64,19 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender public J2KDecoderModule() { - fCache = new J2KDecodeFileCache(CacheFolder); } public void Initialise(Scene scene, IConfigSource source) { + IConfig j2kConfig = source.Configs["J2KDecoder"]; + if (j2kConfig != null) + { + CacheFolder = j2kConfig.GetString("CacheDir", CacheFolder); + CacheTimeout = j2kConfig.GetInt("CacheTimeout", CacheTimeout); + } + + fCache = new J2KDecodeFileCache(CacheFolder, CacheTimeout); + scene.RegisterModuleInterface(this); } @@ -353,6 +362,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender public class J2KDecodeFileCache { private readonly string m_cacheDecodeFolder; + private readonly int m_cacheTimeout; private bool enabled = true; private static readonly ILog m_log @@ -362,9 +372,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender /// Creates a new instance of a file cache /// /// base folder for the cache. Will be created if it doesn't exist - public J2KDecodeFileCache(string pFolder) + public J2KDecodeFileCache(string pFolder, int timeout) { m_cacheDecodeFolder = pFolder; + m_cacheTimeout = timeout; if (!Directory.Exists(pFolder)) { Createj2KCacheFolder(pFolder); @@ -426,6 +437,15 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender return false; } + DateTime creationTime = File.GetCreationTime(filename); + TimeSpan fileAge = DateTime.Now - creationTime; + + if (m_cacheTimeout != 0 && fileAge >= TimeSpan.FromMinutes(m_cacheTimeout)) + { + File.Delete(filename); + return false; + } + string readResult = string.Empty; try -- cgit v1.1 From 2a5b9f77408bfb0fd4e28e7bf28f59894525c365 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 29 Aug 2009 05:29:54 +0100 Subject: the beginning of some changes to the decode cache to address concerns about system load. This commit effectively disables expiration. --- .../Agent/TextureSender/J2KDecoderModule.cs | 39 +++++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 00a247c..df321a2 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -41,6 +41,8 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Agent.TextureSender { + public delegate void J2KDecodeDelegate(UUID AssetId); + public class J2KDecoderModule : IRegionModule, IJ2KDecoder { #region IRegionModule Members @@ -437,15 +439,6 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender return false; } - DateTime creationTime = File.GetCreationTime(filename); - TimeSpan fileAge = DateTime.Now - creationTime; - - if (m_cacheTimeout != 0 && fileAge >= TimeSpan.FromMinutes(m_cacheTimeout)) - { - File.Delete(filename); - return false; - } - string readResult = string.Empty; try @@ -575,6 +568,16 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender return String.Format("j2kCache_{0}.cache", AssetId); } + public UUID AssetIdFromFileName(string fileName) + { + string rawId = fileName.Replace("j2kCache_", "").Replace(".cache", ""); + UUID asset; + if (!UUID.TryParse(rawId, out asset)) + return UUID.Zero; + + return asset; + } + /// /// Creates the Cache Folder /// @@ -639,5 +642,23 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender enabled = false; } } + + public void ScanCacheFiles(J2KDecodeDelegate decode) + { + DirectoryInfo dir = new DirectoryInfo(m_cacheDecodeFolder); + FileInfo[] files = dir.GetFiles("j2kCache_*.cache"); + + foreach (FileInfo f in files) + { + TimeSpan fileAge = DateTime.Now - f.CreationTime; + + if (m_cacheTimeout != 0 && fileAge >= TimeSpan.FromMinutes(m_cacheTimeout)) + { + File.Delete(f.Name); + decode(AssetIdFromFileName(f.Name)); + System.Threading.Thread.Sleep(2000); + } + } + } } } -- cgit v1.1 From 1a6b30e0924644cb4f9b6a771d768fc7d37d7aa0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 29 Aug 2009 05:54:38 +0100 Subject: Add a slow cache cleaner thread. By default, the thread starts a cleanup sweep every 10 minutes. If any texture data is older than 12 hours, it is regenerated and the memory cache is refreshed. After each decode, the thread delays for 5 seconds. --- .../Agent/TextureSender/J2KDecoderModule.cs | 54 +++++++++++++++++++--- 1 file changed, 47 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index df321a2..937f76b 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text; +using System.Threading; using log4net; using Nini.Config; using OpenMetaverse; @@ -38,6 +39,7 @@ using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Agent.TextureSender { @@ -56,8 +58,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender private readonly Dictionary m_cacheddecode = new Dictionary(); private bool OpenJpegFail = false; private string CacheFolder = Util.dataDir() + "/j2kDecodeCache"; - private int CacheTimeout = 60; - private J2KDecodeFileCache fCache; + private int CacheTimeout = 720; + private J2KDecodeFileCache fCache = null; + private Thread CleanerThread = null; + private IAssetService AssetService = null; + private Scene m_Scene = null; /// /// List of client methods to notify of results of decode @@ -70,6 +75,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender public void Initialise(Scene scene, IConfigSource source) { + if (m_Scene == null) + m_Scene = scene; + IConfig j2kConfig = source.Configs["J2KDecoder"]; if (j2kConfig != null) { @@ -77,14 +85,23 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender CacheTimeout = j2kConfig.GetInt("CacheTimeout", CacheTimeout); } - fCache = new J2KDecodeFileCache(CacheFolder, CacheTimeout); + if (fCache == null) + fCache = new J2KDecodeFileCache(CacheFolder, CacheTimeout); scene.RegisterModuleInterface(this); + + if (CleanerThread == null && CacheTimeout != 0) + { + CleanerThread = new Thread(CleanCache); + CleanerThread.Name = "J2KCleanerThread"; + CleanerThread.IsBackground = true; + CleanerThread.Start(); + } } public void PostInitialise() { - + AssetService = m_Scene.AssetService; } public void Close() @@ -340,8 +357,9 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender // Cache Decoded layers lock (m_cacheddecode) { - if (!m_cacheddecode.ContainsKey(AssetId)) - m_cacheddecode.Add(AssetId, layers); + if (m_cacheddecode.ContainsKey(AssetId)) + m_cacheddecode.Remove(AssetId); + m_cacheddecode.Add(AssetId, layers); } @@ -359,6 +377,28 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender } } } + + private void CleanCache() + { + m_log.Info("[J2KDecoderModule]: Cleaner thread started"); + + while (true) + { + if (AssetService != null) + fCache.ScanCacheFiles(RedecodeTexture); + + System.Threading.Thread.Sleep(600000); + } + } + + private void RedecodeTexture(UUID assetID) + { + AssetBase texture = AssetService.Get(assetID.ToString()); + if (texture == null) + return; + + doJ2kDecode(assetID, texture.Data); + } } public class J2KDecodeFileCache @@ -656,7 +696,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender { File.Delete(f.Name); decode(AssetIdFromFileName(f.Name)); - System.Threading.Thread.Sleep(2000); + System.Threading.Thread.Sleep(5000); } } } -- cgit v1.1