From f415eb84e17772a997e8b40ec2d7469cac40b55d Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 13 Mar 2012 20:06:39 +0100 Subject: Implement the cap to send extra physics params to the viewer. Not functional yet because the parameters are not actually stored anywhere yet. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 35cb575..2974058 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -96,6 +96,7 @@ namespace OpenSim.Region.ClientStack.Linden // private static readonly string m_fetchInventoryPath = "0006/"; private static readonly string m_copyFromNotecardPath = "0007/"; // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. + private static readonly string m_getObjectPhysicsDataPath = "0101/"; // These are callbacks which will be setup by the scene so that we can update scene data when we @@ -182,6 +183,8 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); m_HostCapsObj.RegisterHandler("CopyInventoryFromNotecard", new RestStreamHandler("POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard)); + IRequestHandler getObjectPhysicsDataHandler = new RestStreamHandler("POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData); + m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler); // As of RC 1.22.9 of the Linden client this is // supported @@ -799,6 +802,41 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 200; return LLSDHelpers.SerialiseLLSDReply(response); } + + public string GetObjectPhysicsData(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + OSDArray object_ids = (OSDArray)req["object_ids"]; + + for (int i = 0 ; i < object_ids.Count ; i++) + { + UUID uuid = object_ids[i].AsUUID(); + + SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); + if (obj != null) + { + OSDMap object_data = new OSDMap(); + + object_data["PhysicsShapeType"] = OSD.FromInteger(1); + if (false) // Check whether to include the rest + { + object_data["Density"] = OSD.FromReal(1); + object_data["Friction"] = OSD.FromReal(1); + object_data["Restitution"] = OSD.FromReal(1); + object_data["GravityMultiplier"] = OSD.FromReal(1); + } + + resp[uuid.ToString()] = object_data; + } + } + + string response = OSDParser.SerializeLLSDXmlString(resp); + Console.WriteLine(response); + return response; + } } public class AssetUploader -- cgit v1.1 From d4e6834f99db25ad0461cec72b58876fa299844b Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 13 Mar 2012 20:49:16 +0100 Subject: Hook up the new cap to the SOP changes --- .../ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 2974058..df65af9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -820,14 +820,11 @@ namespace OpenSim.Region.ClientStack.Linden { OSDMap object_data = new OSDMap(); - object_data["PhysicsShapeType"] = OSD.FromInteger(1); - if (false) // Check whether to include the rest - { - object_data["Density"] = OSD.FromReal(1); - object_data["Friction"] = OSD.FromReal(1); - object_data["Restitution"] = OSD.FromReal(1); - object_data["GravityMultiplier"] = OSD.FromReal(1); - } + object_data["PhysicsShapeType"] = obj.PhysicsShapeType; + object_data["Density"] = obj.Density; + object_data["Friction"] = obj.Friction; + object_data["Restitution"] = obj.Bounciness; + object_data["GravityMultiplier"] = obj.GravityModifier; resp[uuid.ToString()] = object_data; } -- cgit v1.1 From 84ca09f7c5cec051014181853083e52691bb7e07 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 15 Mar 2012 02:24:13 +0000 Subject: added ObjectPhysicsProperties http event message to send viewer that data. For now on caps/EventQueue, and still only used on a material change... --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 ++++++++ .../Linden/Caps/EventQueue/EventQueueHelper.cs | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 7c07c56..a91b02c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -805,5 +805,13 @@ namespace OpenSim.Region.ClientStack.Linden { return EventQueueHelper.BuildEvent(eventName, eventBody); } + + public void partPhysicsProperties(uint localID, byte physhapetype, + float density, float friction, float bounce, float gravmod,UUID avatarID) + { + OSD item = EventQueueHelper.partPhysicsProperties(localID, physhapetype, + density, friction, bounce, gravmod); + Enqueue(item, avatarID); + } } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 3f49aba..b9222e3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -395,5 +395,25 @@ namespace OpenSim.Region.ClientStack.Linden return message; } + public static OSD partPhysicsProperties(uint localID, byte physhapetype, + float density, float friction, float bounce, float gravmod) + { + + OSDMap physinfo = new OSDMap(6); + physinfo["LocalID"] = localID; + physinfo["Density"] = density; + physinfo["Friction"] = friction; + physinfo["GravityMultiplier"] = gravmod; + physinfo["Restitution"] = bounce; + physinfo["PhysicsShapeType"] = (int)physhapetype; + + OSDArray array = new OSDArray(1); + array.Add(physinfo); + + OSDMap llsdBody = new OSDMap(1); + llsdBody.Add("ObjectData", array); + + return BuildEvent("ObjectPhysicsProperties", llsdBody); + } } } -- cgit v1.1 From 15ad5f492b8150ff81d969a389e32edb35227b19 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 15 Mar 2012 10:25:18 +0000 Subject: Playing with object costs CAPS ... --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 120 ++++++++++++++++++++- 1 file changed, 118 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index df65af9..5542680 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -97,7 +97,9 @@ namespace OpenSim.Region.ClientStack.Linden private static readonly string m_copyFromNotecardPath = "0007/"; // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. private static readonly string m_getObjectPhysicsDataPath = "0101/"; - + private static readonly string m_getObjectCostPath = "0102/"; + private static readonly string m_ResourceCostSelectedPath = "0103/"; + // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls @@ -185,7 +187,12 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler("CopyInventoryFromNotecard", new RestStreamHandler("POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard)); IRequestHandler getObjectPhysicsDataHandler = new RestStreamHandler("POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData); m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler); - + IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); + m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); + IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); + m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); + + // As of RC 1.22.9 of the Linden client this is // supported @@ -834,6 +841,115 @@ namespace OpenSim.Region.ClientStack.Linden Console.WriteLine(response); return response; } + + public string GetObjectCost(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + // see being triggered but see no efect .. have something wrong ?? + // + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + + OSDArray object_ids = (OSDArray)req["object_ids"]; + + for (int i = 0; i < object_ids.Count; i++) + { + UUID uuid = object_ids[i].AsUUID(); + + // only see root parts .. so guess should go by SOG only + SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); + if (obj != null) + { + OSDMap object_data = new OSDMap(); + + object_data["linked_set_resource_cost"] = 1.0f; + object_data["resource_cost"] = 1.0f; + object_data["physics_cost"] = 1.0f; + object_data["linked_set_physics_cost"] = 1.0f; + + resp[uuid.ToString()] = object_data; + } + } + + string response = OSDParser.SerializeLLSDXmlString(resp); + Console.WriteLine(response); + return response; + } + + public string ResourceCostSelected(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + + + float phys=0; + float stream=0; + float simul=0; + + if (req.ContainsKey("selected_roots")) + { + OSDArray object_ids = (OSDArray)req["selected_roots"]; + + // should go by SOG suming costs for all parts + // ll v3 works ok with several objects select we get the list and adds ok + // FS calls per object so results are wrong guess fs bug + for (int i = 0; i < object_ids.Count; i++) + { + UUID uuid = object_ids[i].AsUUID(); + + SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); + if (obj != null) + { + phys += 0.1f; // just to see... + stream += 0.2f; + simul += 0.5f; + } + } + } + else if (req.ContainsKey("selected_prims")) + { + OSDArray object_ids = (OSDArray)req["selected_prims"]; + + // don't see in use in any of the 2 viewers + // guess it should be for edit linked but... nothing + // should go to SOP per part + for (int i = 0; i < object_ids.Count; i++) + { + UUID uuid = object_ids[i].AsUUID(); + + SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); + if (obj != null) + { + phys += 0.1f; + stream += 0.2f; + simul += 0.5f; + } + } + } + + if (simul != 0) + { + OSDMap object_data = new OSDMap(); + + object_data["physics"] = phys; + object_data["streaming"] = stream; + object_data["simulation"] = simul; + + resp["selected"] = object_data; + } + + string response = OSDParser.SerializeLLSDXmlString(resp); + Console.WriteLine(response); + return response; + } + + + + + } public class AssetUploader -- cgit v1.1 From ae8e089b9c73a6a675038759e3e3f9491819eb72 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 16 Mar 2012 15:33:49 +0000 Subject: some more work on costs --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 56 +++++++++++++--------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 5542680..dfd5c98 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -845,9 +845,7 @@ namespace OpenSim.Region.ClientStack.Linden public string GetObjectCost(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) - { - // see being triggered but see no efect .. have something wrong ?? - // + { OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); OSDMap resp = new OSDMap(); @@ -856,19 +854,29 @@ namespace OpenSim.Region.ClientStack.Linden for (int i = 0; i < object_ids.Count; i++) { UUID uuid = object_ids[i].AsUUID(); + + SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); - // only see root parts .. so guess should go by SOG only - SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); - if (obj != null) + if (part != null) { - OSDMap object_data = new OSDMap(); + SceneObjectGroup grp = part.ParentGroup; + if (grp != null) + { + float linksetCost; + float linksetPhysCost; + float partCost; + float partPhysCost; - object_data["linked_set_resource_cost"] = 1.0f; - object_data["resource_cost"] = 1.0f; - object_data["physics_cost"] = 1.0f; - object_data["linked_set_physics_cost"] = 1.0f; + grp.GetResourcesCosts(part, out linksetCost, out linksetPhysCost, out partCost, out partPhysCost); - resp[uuid.ToString()] = object_data; + OSDMap object_data = new OSDMap(); + object_data["linked_set_resource_cost"] = linksetCost; + object_data["resource_cost"] = partCost; + object_data["physics_cost"] = partPhysCost; + object_data["linked_set_physics_cost"] = linksetPhysCost; + + resp[uuid.ToString()] = object_data; + } } } @@ -899,13 +907,17 @@ namespace OpenSim.Region.ClientStack.Linden for (int i = 0; i < object_ids.Count; i++) { UUID uuid = object_ids[i].AsUUID(); + float Physc; + float simulc; + float streamc; - SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); - if (obj != null) + SceneObjectGroup grp = m_Scene.GetGroupByPrim(uuid); + if (grp != null) { - phys += 0.1f; // just to see... - stream += 0.2f; - simul += 0.5f; + grp.GetSelectedCosts(out Physc, out streamc, out simulc); + phys += Physc; + stream += streamc; + simul += simulc; } } } @@ -920,12 +932,12 @@ namespace OpenSim.Region.ClientStack.Linden { UUID uuid = object_ids[i].AsUUID(); - SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); - if (obj != null) + SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); + if (part != null) { - phys += 0.1f; - stream += 0.2f; - simul += 0.5f; + phys += part.PhysicsCost; + stream += part.StreamingCost; + simul += part.SimulationCost; } } } -- cgit v1.1 From 618244f285a521971808bc649be538cf831f3e66 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 19 Mar 2012 14:39:19 +0100 Subject: Remove debug output using Console.WriteLine and trim excessive whitespace --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index dfd5c98..6c44175 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -838,7 +838,6 @@ namespace OpenSim.Region.ClientStack.Linden } string response = OSDParser.SerializeLLSDXmlString(resp); - Console.WriteLine(response); return response; } @@ -881,7 +880,6 @@ namespace OpenSim.Region.ClientStack.Linden } string response = OSDParser.SerializeLLSDXmlString(resp); - Console.WriteLine(response); return response; } @@ -954,14 +952,8 @@ namespace OpenSim.Region.ClientStack.Linden } string response = OSDParser.SerializeLLSDXmlString(resp); - Console.WriteLine(response); return response; } - - - - - } public class AssetUploader -- cgit v1.1 From 02cb0bf80a0b67eb0316ac74e1ea9741bfce1385 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Jul 2012 17:40:02 +0100 Subject: added a timeout paramenter to PollServiceEventArgs, so each type can define it's timeout --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index a91b02c..016ed97 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -361,7 +361,7 @@ namespace OpenSim.Region.ClientStack.Linden // This will persist this beyond the expiry of the caps handlers MainServer.Instance.AddPollServiceHTTPHandler( capsBase + EventQueueGetUUID.ToString() + "/", - new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); + new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID,1000)); // 1 sec timeout Random rnd = new Random(Environment.TickCount); lock (m_ids) -- cgit v1.1 From f21fdff4f98a3916aa63ae84f335bfb763345c54 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 21:58:07 +0200 Subject: Actually add the module --- .../ClientStack/Linden/Caps/RegionConsoleModule.cs | 234 +++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs new file mode 100644 index 0000000..36af55f --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs @@ -0,0 +1,234 @@ +/* + * 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 System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Drawing; +using System.Drawing.Imaging; +using System.Reflection; +using System.IO; +using System.Web; +using log4net; +using Nini.Config; +using Mono.Addins; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenMetaverse.Imaging; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OpenSim.Capabilities.Handlers; + +namespace OpenSim.Region.ClientStack.Linden +{ + + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionConsoleModule")] + public class RegionConsoleModule : INonSharedRegionModule, IRegionConsole + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + private IEventQueue m_eventQueue; + private Commands m_commands = new Commands(); + public ICommands Commands { get { return m_commands; } } + + public void Initialise(IConfigSource source) + { + m_commands.AddCommand( "Help", false, "help", "help []", "Display help on a particular command or on a list of commands in a category", Help); + } + + public void AddRegion(Scene s) + { + m_scene = s; + m_scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene s) + { + m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene = null; + } + + public void RegionLoaded(Scene s) + { + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + m_eventQueue = m_scene.RequestModuleInterface(); + } + + public void PostInitialise() + { + } + + public void Close() { } + + public string Name { get { return "RegionConsoleModule"; } } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void RegisterCaps(UUID agentID, Caps caps) + { + if (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(agentID)) + return; + + UUID capID = UUID.Random(); + + m_log.DebugFormat("[REGION CONSOLE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); + caps.RegisterHandler( + "SimConsoleAsync", + new ConsoleHandler("/CAPS/" + capID + "/", "SimConsoleAsync", agentID, this, m_scene)); + } + + public void SendConsoleOutput(UUID agentID, string message) + { + OSD osd = OSD.FromString(message); + + m_eventQueue.Enqueue(EventQueueHelper.BuildEvent("SimConsoleResponse", osd), agentID); + } + + public bool RunCommand(string command, UUID invokerID) + { + string[] parts = Parser.Parse(command); + Array.Resize(ref parts, parts.Length + 1); + parts[parts.Length - 1] = invokerID.ToString(); + + if (m_commands.Resolve(parts).Length == 0) + return false; + + return true; + } + + private void Help(string module, string[] cmd) + { + UUID agentID = new UUID(cmd[cmd.Length - 1]); + Array.Resize(ref cmd, cmd.Length - 1); + + List help = Commands.GetHelp(cmd); + + string reply = String.Empty; + + foreach (string s in help) + { + reply += s + "\n"; + } + + SendConsoleOutput(agentID, reply); + } + + public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) + { + m_commands.AddCommand(module, shared, command, help, longhelp, fn); + } + } + + public class ConsoleHandler : BaseStreamHandler + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private RegionConsoleModule m_consoleModule; + private UUID m_agentID; + private bool m_isGod; + private Scene m_scene; + private bool m_consoleIsOn = false; + + public ConsoleHandler(string path, string name, UUID agentID, RegionConsoleModule module, Scene scene) + :base("POST", path, name, agentID.ToString()) + { + m_agentID = agentID; + m_consoleModule = module; + m_scene = scene; + + m_isGod = m_scene.Permissions.IsGod(agentID); + } + + public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + StreamReader reader = new StreamReader(request); + string message = reader.ReadToEnd(); + + OSD osd = OSDParser.DeserializeLLSDXml(message); + + string cmd = osd.AsString(); + if (cmd == "set console on") + { + if (m_isGod) + { + MainConsole.Instance.OnOutput += ConsoleSender; + m_consoleIsOn = true; + m_consoleModule.SendConsoleOutput(m_agentID, "Console is now on"); + } + return new byte[0]; + } + else if (cmd == "set console off") + { + MainConsole.Instance.OnOutput -= ConsoleSender; + m_consoleIsOn = false; + m_consoleModule.SendConsoleOutput(m_agentID, "Console is now off"); + return new byte[0]; + } + + if (m_consoleIsOn == false && m_consoleModule.RunCommand(osd.AsString().Trim(), m_agentID)) + return new byte[0]; + + if (m_isGod && m_consoleIsOn) + { + MainConsole.Instance.RunCommand(osd.AsString().Trim()); + } + else + { + m_consoleModule.SendConsoleOutput(m_agentID, "Unknown command"); + } + + return new byte[0]; + } + + private void ConsoleSender(string text) + { + m_consoleModule.SendConsoleOutput(m_agentID, text); + } + + private void OnMakeChildAgent(ScenePresence presence) + { + if (presence.UUID == m_agentID) + { + MainConsole.Instance.OnOutput -= ConsoleSender; + m_consoleIsOn = false; + } + } + } +} -- cgit v1.1 From 0a959343a58b06d68d86be4607003b1c3d83a981 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 18 Aug 2012 22:36:48 +0200 Subject: Make the console output from the reigon console hookable --- OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs index 36af55f..413536d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs @@ -64,6 +64,8 @@ namespace OpenSim.Region.ClientStack.Linden private Commands m_commands = new Commands(); public ICommands Commands { get { return m_commands; } } + public event ConsoleMessage OnConsoleMessage; + public void Initialise(IConfigSource source) { m_commands.AddCommand( "Help", false, "help", "help []", "Display help on a particular command or on a list of commands in a category", Help); @@ -118,6 +120,11 @@ namespace OpenSim.Region.ClientStack.Linden OSD osd = OSD.FromString(message); m_eventQueue.Enqueue(EventQueueHelper.BuildEvent("SimConsoleResponse", osd), agentID); + + ConsoleMessage handlerConsoleMessage = OnConsoleMessage; + + if (handlerConsoleMessage != null) + handlerConsoleMessage( agentID, message); } public bool RunCommand(string command, UUID invokerID) -- cgit v1.1 From 7e17f4296e91129990c15cdaaa1689922a57f9aa Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 24 Aug 2012 23:48:01 +0200 Subject: Fix background inventory loading (Viewer 3) so it won't lag out the sim --- .../Linden/Caps/WebFetchInvDescModule.cs | 152 ++++++++++++++------- 1 file changed, 103 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 2359bd6..61387ed 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -27,12 +27,15 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Reflection; +using System.Threading; using log4net; using Nini.Config; using Mono.Addins; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -48,67 +51,49 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class WebFetchInvDescModule : INonSharedRegionModule { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; private IInventoryService m_InventoryService; private ILibraryService m_LibraryService; - private bool m_Enabled; + private WebFetchInvDescHandler m_webFetchHandler; - private string m_fetchInventoryDescendents2Url; - private string m_webFetchInventoryDescendentsUrl; + private ManualResetEvent m_ev = new ManualResetEvent(true); + private object m_lock = new object(); - private WebFetchInvDescHandler m_webFetchHandler; + private Dictionary m_capsDict = new Dictionary(); + private Dictionary m_requests = new Dictionary(); #region ISharedRegionModule Members public void Initialise(IConfigSource source) { - IConfig config = source.Configs["ClientStack.LindenCaps"]; - if (config == null) - return; - - m_fetchInventoryDescendents2Url = config.GetString("Cap_FetchInventoryDescendents2", string.Empty); - m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty); - - if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty) - { - m_Enabled = true; - } } public void AddRegion(Scene s) { - if (!m_Enabled) - return; - m_scene = s; } public void RemoveRegion(Scene s) { - if (!m_Enabled) - return; - m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; m_scene = null; } public void RegionLoaded(Scene s) { - if (!m_Enabled) - return; - m_InventoryService = m_scene.InventoryService; m_LibraryService = m_scene.LibraryService; // We'll reuse the same handler for all requests. - if (m_fetchInventoryDescendents2Url == "localhost" || m_webFetchInventoryDescendentsUrl == "localhost") - m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); + m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); m_scene.EventManager.OnRegisterCaps += RegisterCaps; + m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; } public void PostInitialise() @@ -128,41 +113,110 @@ namespace OpenSim.Region.ClientStack.Linden private void RegisterCaps(UUID agentID, Caps caps) { - if (m_webFetchInventoryDescendentsUrl != "") - RegisterFetchCap(agentID, caps, "WebFetchInventoryDescendents", m_webFetchInventoryDescendentsUrl); + string capUrl = "/CAPS/" + UUID.Random() + "/"; + + // Register this as a poll service + PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, agentID, 300000); + args.Type = PollServiceEventArgs.EventType.Inventory; + MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); + + string hostName = m_scene.RegionInfo.ExternalHostName; + uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; + string protocol = "http"; + + if (MainServer.Instance.UseSSL) + { + hostName = MainServer.Instance.SSLCommonName; + port = MainServer.Instance.SSLPort; + protocol = "https"; + } + caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); - if (m_fetchInventoryDescendents2Url != "") - RegisterFetchCap(agentID, caps, "FetchInventoryDescendents2", m_fetchInventoryDescendents2Url); + m_capsDict[agentID] = capUrl; } - private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url) + private void DeregisterCaps(UUID agentID, Caps caps) { string capUrl; - if (url == "localhost") + if (m_capsDict.TryGetValue(agentID, out capUrl)) { - capUrl = "/CAPS/" + UUID.Random(); + MainServer.Instance.RemoveHTTPHandler("", capUrl); + m_capsDict.Remove(agentID); + } + } - IRequestHandler reqHandler - = new RestStreamHandler( - "POST", - capUrl, - m_webFetchHandler.FetchInventoryDescendentsRequest, - "FetchInventoryDescendents2", - agentID.ToString()); + public void HttpRequestHandler(UUID requestID, Hashtable request) + { + m_log.DebugFormat("[FETCH2]: Received request {0}", requestID); + m_requests[requestID] = request; + } - caps.RegisterHandler(capName, reqHandler); + private bool HasEvents(UUID requestID, UUID sessionID) + { + lock (m_lock) + { + if (m_ev.WaitOne(0)) + { + m_ev.Reset(); + return true; + } + return false; } - else + } + + private Hashtable NoEvents(UUID requestID, UUID sessionID) + { + m_requests.Remove(requestID); + + Hashtable response = new Hashtable(); + + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + return response; + } + + private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) + { + Hashtable response = new Hashtable(); + + response["int_response_code"] = 500; + response["str_response_string"] = "Internal error"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + try { - capUrl = url; + Hashtable requestHash; + if (!m_requests.TryGetValue(requestID, out requestHash)) + { + lock (m_lock) + m_ev.Set(); + response["str_response_string"] = "Invalid request"; + return response; + } + + m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID); - caps.RegisterHandler(capName, capUrl); + string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null); + + m_requests.Remove(requestID); + + response["int_response_code"] = 200; + response["str_response_string"] = reply; + } + finally + { + lock (m_lock) + m_ev.Set(); } -// m_log.DebugFormat( -// "[WEB FETCH INV DESC MODULE]: Registered capability {0} at {1} in region {2} for {3}", -// capName, capUrl, m_scene.RegionInfo.RegionName, agentID); + return response; } } -} \ No newline at end of file +} -- cgit v1.1 From 6d48dbf8caaf862d096bf5a7d39fb1a28afe46b7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 24 Aug 2012 23:49:31 +0200 Subject: Remove debug spam --- OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 61387ed..b77ead3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -148,7 +148,7 @@ namespace OpenSim.Region.ClientStack.Linden public void HttpRequestHandler(UUID requestID, Hashtable request) { - m_log.DebugFormat("[FETCH2]: Received request {0}", requestID); +// m_log.DebugFormat("[FETCH2]: Received request {0}", requestID); m_requests[requestID] = request; } @@ -201,7 +201,7 @@ namespace OpenSim.Region.ClientStack.Linden return response; } - m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID); +// m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID); string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null); -- cgit v1.1 From d4fad2ba42445f72b8a04378b21818ec82ab1089 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 4 Sep 2012 07:32:03 +0100 Subject: a forgotten file plus minor changes. Imp and SL viewer seem to preserve flight. FS 4.2.2 does not. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index b9222e3..fb41d23 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -151,6 +151,10 @@ namespace OpenSim.Region.ClientStack.Linden ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, UUID agentID) { + ulong tpflags = 1L << 4; // AgentManager.TeleportFlags.ViaLocation + if((flags & (uint)TeleportFlags.IsFlying) != 0) + tpflags |= 1 << 13; // IsFLying; + OSDMap info = new OSDMap(); info.Add("AgentID", OSD.FromUUID(agentID)); info.Add("LocationID", OSD.FromInteger(4)); // TODO what is this? @@ -159,7 +163,8 @@ namespace OpenSim.Region.ClientStack.Linden info.Add("SimAccess", OSD.FromInteger(simAccess)); info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); - info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation +// info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation + info.Add("TeleportFlags", OSD.FromULong(tpflags)); OSDArray infoArr = new OSDArray(); infoArr.Add(info); -- cgit v1.1 From c298ae9e75f00f2009c87de30b295af20dcb86a2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 4 Sep 2012 10:51:43 +0100 Subject: bug fix --- .../ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index fb41d23..7dcf137 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -151,9 +151,11 @@ namespace OpenSim.Region.ClientStack.Linden ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, UUID agentID) { - ulong tpflags = 1L << 4; // AgentManager.TeleportFlags.ViaLocation - if((flags & (uint)TeleportFlags.IsFlying) != 0) - tpflags |= 1 << 13; // IsFLying; + // not sure why flags get overwritten here + if ((flags & (uint)TeleportFlags.IsFlying) != 0) + flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying; + else + flags = (uint)TeleportFlags.ViaLocation; OSDMap info = new OSDMap(); info.Add("AgentID", OSD.FromUUID(agentID)); @@ -164,7 +166,7 @@ namespace OpenSim.Region.ClientStack.Linden info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); // info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation - info.Add("TeleportFlags", OSD.FromULong(tpflags)); + info.Add("TeleportFlags", OSD.FromUInteger(flags)); OSDArray infoArr = new OSDArray(); infoArr.Add(info); -- cgit v1.1 From b7737b7273e87fcd9159d81f9cdc784381f94a25 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 10 Sep 2012 01:20:34 +0100 Subject: webFetchInventory: change control event to simple flag, adjust locking --- .../Linden/Caps/WebFetchInvDescModule.cs | 43 ++++++++++++++++------ 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index b77ead3..2475b1f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -60,11 +60,12 @@ namespace OpenSim.Region.ClientStack.Linden private WebFetchInvDescHandler m_webFetchHandler; - private ManualResetEvent m_ev = new ManualResetEvent(true); +// private ManualResetEvent m_ev = new ManualResetEvent(true); private object m_lock = new object(); private Dictionary m_capsDict = new Dictionary(); private Dictionary m_requests = new Dictionary(); + bool m_busy = false; #region ISharedRegionModule Members @@ -116,7 +117,9 @@ namespace OpenSim.Region.ClientStack.Linden string capUrl = "/CAPS/" + UUID.Random() + "/"; // Register this as a poll service + // absurd large timeout to tune later to make a bit less than viewer PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, agentID, 300000); + args.Type = PollServiceEventArgs.EventType.Inventory; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); @@ -133,6 +136,8 @@ namespace OpenSim.Region.ClientStack.Linden caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); m_capsDict[agentID] = capUrl; + + m_busy = false; } private void DeregisterCaps(UUID agentID, Caps caps) @@ -149,25 +154,30 @@ namespace OpenSim.Region.ClientStack.Linden public void HttpRequestHandler(UUID requestID, Hashtable request) { // m_log.DebugFormat("[FETCH2]: Received request {0}", requestID); - m_requests[requestID] = request; + lock(m_lock) + m_requests[requestID] = request; } private bool HasEvents(UUID requestID, UUID sessionID) { lock (m_lock) { +/* if (m_ev.WaitOne(0)) { m_ev.Reset(); return true; } return false; + */ + return !m_busy; } } private Hashtable NoEvents(UUID requestID, UUID sessionID) { - m_requests.Remove(requestID); + lock(m_lock) + m_requests.Remove(requestID); Hashtable response = new Hashtable(); @@ -177,11 +187,17 @@ namespace OpenSim.Region.ClientStack.Linden response["keepalive"] = false; response["reusecontext"] = false; + lock (m_lock) + m_busy = false; + return response; } private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) { + lock (m_lock) + m_busy = true; + Hashtable response = new Hashtable(); response["int_response_code"] = 500; @@ -192,20 +208,24 @@ namespace OpenSim.Region.ClientStack.Linden try { + Hashtable requestHash; - if (!m_requests.TryGetValue(requestID, out requestHash)) + lock (m_lock) { - lock (m_lock) - m_ev.Set(); - response["str_response_string"] = "Invalid request"; - return response; + if (!m_requests.TryGetValue(requestID, out requestHash)) + { + m_busy = false; + // m_ev.Set(); + response["str_response_string"] = "Invalid request"; + return response; + } + m_requests.Remove(requestID); } // m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID); string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null); - - m_requests.Remove(requestID); + response["int_response_code"] = 200; response["str_response_string"] = reply; @@ -213,7 +233,8 @@ namespace OpenSim.Region.ClientStack.Linden finally { lock (m_lock) - m_ev.Set(); +// m_ev.Set(); + m_busy = false; } return response; -- cgit v1.1 From 657428a43906c5e65ad56ed96fa05d82f84d6c9b Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 10 Sep 2012 01:52:02 +0200 Subject: Remove commented code --- .../Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 2475b1f..e996fe8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -60,7 +60,6 @@ namespace OpenSim.Region.ClientStack.Linden private WebFetchInvDescHandler m_webFetchHandler; -// private ManualResetEvent m_ev = new ManualResetEvent(true); private object m_lock = new object(); private Dictionary m_capsDict = new Dictionary(); @@ -162,14 +161,6 @@ namespace OpenSim.Region.ClientStack.Linden { lock (m_lock) { -/* - if (m_ev.WaitOne(0)) - { - m_ev.Reset(); - return true; - } - return false; - */ return !m_busy; } } @@ -215,7 +206,6 @@ namespace OpenSim.Region.ClientStack.Linden if (!m_requests.TryGetValue(requestID, out requestHash)) { m_busy = false; - // m_ev.Set(); response["str_response_string"] = "Invalid request"; return response; } @@ -233,7 +223,6 @@ namespace OpenSim.Region.ClientStack.Linden finally { lock (m_lock) -// m_ev.Set(); m_busy = false; } -- cgit v1.1 From a6753c14a509e11f65829b87070b440ac3b87c4a Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 10:39:43 +0200 Subject: Revamp the v3 inventory sending. Uses threads and some nifty mechanics to leverage the Poll Service without blocking it's workers. --- .../Linden/Caps/WebFetchInvDescModule.cs | 198 ++++++++++++--------- 1 file changed, 117 insertions(+), 81 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index e996fe8..4908c2c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -42,6 +42,7 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using Caps = OpenSim.Framework.Capabilities.Caps; using OpenSim.Capabilities.Handlers; +using OpenSim.Framework.Monitoring; namespace OpenSim.Region.ClientStack.Linden { @@ -58,13 +59,13 @@ namespace OpenSim.Region.ClientStack.Linden private IInventoryService m_InventoryService; private ILibraryService m_LibraryService; - private WebFetchInvDescHandler m_webFetchHandler; - - private object m_lock = new object(); + private static WebFetchInvDescHandler m_webFetchHandler; private Dictionary m_capsDict = new Dictionary(); - private Dictionary m_requests = new Dictionary(); - bool m_busy = false; + private static Thread[] m_workerThreads = null; + + private static OpenMetaverse.BlockingQueue m_queue = + new OpenMetaverse.BlockingQueue(); #region ISharedRegionModule Members @@ -94,6 +95,22 @@ namespace OpenSim.Region.ClientStack.Linden m_scene.EventManager.OnRegisterCaps += RegisterCaps; m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; + + if (m_workerThreads == null) + { + m_workerThreads = new Thread[2]; + + for (uint i = 0; i < 2; i++) + { + m_workerThreads[i] = Watchdog.StartThread(DoInventoryRequests, + String.Format("InventoryWorkerThread{0}", i), + ThreadPriority.Normal, + false, + true, + null, + int.MaxValue); + } + } } public void PostInitialise() @@ -111,13 +128,103 @@ namespace OpenSim.Region.ClientStack.Linden #endregion + ~WebFetchInvDescModule() + { + foreach (Thread t in m_workerThreads) + t.Abort(); + } + + private class PollServiceInventoryEventArgs : PollServiceEventArgs + { + private List requests = + new List(); + private Dictionary responses = + new Dictionary(); + + public PollServiceInventoryEventArgs(UUID pId) : + base(null, null, null, null, pId, 30000) + { + HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; + GetEvents = (x, y, s) => + { + try + { + return this.responses[x]; + } + finally + { + responses.Remove(x); + } + }; + + Request = (x, y) => + { + y["RequestID"] = x.ToString(); + lock (this.requests) + this.requests.Add(y); + + m_queue.Enqueue(this); + }; + + NoEvents = (x, y) => + { + lock (this.requests) + { + Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); + requests.Remove(request); + } + + Hashtable response = new Hashtable(); + + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + return response; + }; + } + + public void Process() + { + Hashtable request = null; + + try + { + lock (this.requests) + { + request = requests[0]; + requests.RemoveAt(0); + } + } + catch + { + return; + } + + UUID requestID = new UUID(request["RequestID"].ToString()); + + Hashtable response = new Hashtable(); + + response["int_response_code"] = 200; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null); + + responses[requestID] = response; + } + } + private void RegisterCaps(UUID agentID, Caps caps) { string capUrl = "/CAPS/" + UUID.Random() + "/"; // Register this as a poll service // absurd large timeout to tune later to make a bit less than viewer - PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, agentID, 300000); + PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); args.Type = PollServiceEventArgs.EventType.Inventory; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); @@ -135,8 +242,6 @@ namespace OpenSim.Region.ClientStack.Linden caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); m_capsDict[agentID] = capUrl; - - m_busy = false; } private void DeregisterCaps(UUID agentID, Caps caps) @@ -150,83 +255,14 @@ namespace OpenSim.Region.ClientStack.Linden } } - public void HttpRequestHandler(UUID requestID, Hashtable request) + private void DoInventoryRequests() { -// m_log.DebugFormat("[FETCH2]: Received request {0}", requestID); - lock(m_lock) - m_requests[requestID] = request; - } - - private bool HasEvents(UUID requestID, UUID sessionID) - { - lock (m_lock) + while (true) { - return !m_busy; - } - } - - private Hashtable NoEvents(UUID requestID, UUID sessionID) - { - lock(m_lock) - m_requests.Remove(requestID); - - Hashtable response = new Hashtable(); - - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - lock (m_lock) - m_busy = false; + PollServiceInventoryEventArgs args = m_queue.Dequeue(); - return response; - } - - private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) - { - lock (m_lock) - m_busy = true; - - Hashtable response = new Hashtable(); - - response["int_response_code"] = 500; - response["str_response_string"] = "Internal error"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - try - { - - Hashtable requestHash; - lock (m_lock) - { - if (!m_requests.TryGetValue(requestID, out requestHash)) - { - m_busy = false; - response["str_response_string"] = "Invalid request"; - return response; - } - m_requests.Remove(requestID); - } - -// m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID); - - string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null); - - - response["int_response_code"] = 200; - response["str_response_string"] = reply; - } - finally - { - lock (m_lock) - m_busy = false; + args.Process(); } - - return response; } } } -- cgit v1.1 From 94a8e5572b1529190a174f29f866b65e7b2ccc0e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 15:07:32 +0200 Subject: Remove the unused NewFileAgentInventoryVariablePrice module. --- .../NewFileAgentInventoryVariablePriceModule.cs | 296 --------------------- 1 file changed, 296 deletions(-) delete mode 100644 OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs deleted file mode 100644 index 52c4f44..0000000 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ /dev/null @@ -1,296 +0,0 @@ -/* - * 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 System.Collections; -using System.Collections.Specialized; -using System.Reflection; -using System.IO; -using System.Web; -using Mono.Addins; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; -using Caps = OpenSim.Framework.Capabilities.Caps; -using OpenSim.Framework.Capabilities; - -namespace OpenSim.Region.ClientStack.Linden -{ - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Scene m_scene; -// private IAssetService m_assetService; - private bool m_dumpAssetsToFile = false; - private bool m_enabled = true; - private int m_levelUpload = 0; - - #region IRegionModuleBase Members - - - public Type ReplaceableInterface - { - get { return null; } - } - - public void Initialise(IConfigSource source) - { - IConfig meshConfig = source.Configs["Mesh"]; - if (meshConfig == null) - return; - - m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); - m_levelUpload = meshConfig.GetInt("LevelUpload", 0); - } - - public void AddRegion(Scene pScene) - { - m_scene = pScene; - } - - public void RemoveRegion(Scene scene) - { - - m_scene.EventManager.OnRegisterCaps -= RegisterCaps; - m_scene = null; - } - - public void RegionLoaded(Scene scene) - { - -// m_assetService = m_scene.RequestModuleInterface(); - m_scene.EventManager.OnRegisterCaps += RegisterCaps; - } - - #endregion - - - #region IRegionModule Members - - - - public void Close() { } - - public string Name { get { return "NewFileAgentInventoryVariablePriceModule"; } } - - - public void RegisterCaps(UUID agentID, Caps caps) - { - if(!m_enabled) - return; - - UUID capID = UUID.Random(); - -// m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID); - caps.RegisterHandler( - "NewFileAgentInventoryVariablePrice", - new LLSDStreamhandler( - "POST", - "/CAPS/" + capID.ToString(), - req => NewAgentInventoryRequest(req, agentID), - "NewFileAgentInventoryVariablePrice", - agentID.ToString())); - } - - #endregion - - public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) - { - //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit - // you need to be aware of this - - //if (llsdRequest.asset_type == "texture" || - // llsdRequest.asset_type == "animation" || - // llsdRequest.asset_type == "sound") - // { - // check user level - - ScenePresence avatar = null; - IClientAPI client = null; - m_scene.TryGetScenePresence(agentID, out avatar); - - if (avatar != null) - { - client = avatar.ControllingClient; - - if (avatar.UserLevel < m_levelUpload) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } - } - - // check funds - IMoneyModule mm = m_scene.RequestModuleInterface(); - - if (mm != null) - { - if (!mm.UploadCovered(agentID, mm.UploadCharge)) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } - } - - // } - - string assetName = llsdRequest.name; - string assetDes = llsdRequest.description; - string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; - UUID newAsset = UUID.Random(); - UUID newInvItem = UUID.Random(); - UUID parentFolder = llsdRequest.folder_id; - string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; - - AssetUploader uploader = - new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); - - MainServer.Instance.AddStreamHandler( - new BinaryStreamHandler( - "POST", - capsBase + uploaderPath, - uploader.uploaderCaps, - "NewFileAgentInventoryVariablePrice", - agentID.ToString())); - - string protocol = "http://"; - - if (MainServer.Instance.UseSSL) - protocol = "https://"; - - string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + - uploaderPath; - - - LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - - uploadResponse.rsvp = uploaderURL; - uploadResponse.state = "upload"; - uploadResponse.resource_cost = 0; - uploadResponse.upload_price = 0; - - uploader.OnUpLoad += //UploadCompleteHandler; - - delegate( - string passetName, string passetDescription, UUID passetID, - UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, - string passetType) - { - UploadCompleteHandler(passetName, passetDescription, passetID, - pinventoryItem, pparentFolder, pdata, pinventoryType, - passetType,agentID); - }; - - return uploadResponse; - } - - public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType,UUID AgentID) - { -// m_log.DebugFormat( -// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem); - - sbyte assType = 0; - sbyte inType = 0; - - if (inventoryType == "sound") - { - inType = 1; - assType = 1; - } - else if (inventoryType == "animation") - { - inType = 19; - assType = 20; - } - else if (inventoryType == "wearable") - { - inType = 18; - switch (assetType) - { - case "bodypart": - assType = 13; - break; - case "clothing": - assType = 5; - break; - } - } - else if (inventoryType == "mesh") - { - inType = (sbyte)InventoryType.Mesh; - assType = (sbyte)AssetType.Mesh; - } - - AssetBase asset; - asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); - asset.Data = data; - - if (m_scene.AssetService != null) - m_scene.AssetService.Store(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.Owner = AgentID; - item.CreatorId = AgentID.ToString(); - item.ID = inventoryItem; - item.AssetID = asset.FullID; - item.Description = assetDescription; - item.Name = assetName; - item.AssetType = assType; - item.InvType = inType; - item.Folder = parentFolder; - item.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - item.BasePermissions = (uint)PermissionMask.All; - item.EveryOnePermissions = 0; - item.NextPermissions = (uint)PermissionMask.All; - item.CreationDate = Util.UnixTimeSinceEpoch(); - m_scene.AddInventoryItem(item); - } - } -} -- cgit v1.1 From bd1d9a214b7f8750427d670566c8f99ff62f33c4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 17:28:13 +0200 Subject: Add the option to have variable costing for uploads --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 51 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 88c4d7f..097e224 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -60,7 +60,7 @@ namespace OpenSim.Region.ClientStack.Linden public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors); - public delegate void NewInventoryItem(UUID userID, InventoryItemBase item); + public delegate void NewInventoryItem(UUID userID, InventoryItemBase item, uint cost); public delegate void NewAsset(AssetBase asset); @@ -386,6 +386,38 @@ namespace OpenSim.Region.ClientStack.Linden return UUID.Zero; } + private delegate void UploadWithCostCompleteDelegate(string assetName, + string assetDescription, UUID assetID, UUID inventoryItem, + UUID parentFolder, byte[] data, string inventoryType, + string assetType, uint cost); + + private class AssetUploaderWithCost : AssetUploader + { + private uint m_cost; + + public event UploadWithCostCompleteDelegate OnUpLoad; + + public AssetUploaderWithCost(string assetName, string description, UUID assetID, + UUID inventoryItem, UUID parentFolderID, string invType, string assetType, + string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : + base(assetName, description, assetID, inventoryItem, parentFolderID, + invType, assetType, path, httpServer, dumpAssetsToFile) + { + m_cost = cost; + + base.OnUpLoad += UploadCompleteHandler; + } + + private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, + UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, + string assetType) + { + OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, + data, inventoryType, assetType, m_cost); + } + } + + /// /// /// @@ -396,6 +428,8 @@ namespace OpenSim.Region.ClientStack.Linden //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); + uint cost = 0; + if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || llsdRequest.asset_type == "sound") @@ -428,7 +462,10 @@ namespace OpenSim.Region.ClientStack.Linden if (mm != null) { - if (!mm.UploadCovered(client.AgentId, mm.UploadCharge)) + // XPTO: The cost should be calculated about here + cost = (uint)mm.UploadCharge; + + if (!mm.UploadCovered(client.AgentId, (int)cost)) { client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); @@ -449,9 +486,9 @@ namespace OpenSim.Region.ClientStack.Linden UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = - new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile); + AssetUploaderWithCost uploader = + new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -484,7 +521,7 @@ namespace OpenSim.Region.ClientStack.Linden /// public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType) + string assetType, uint cost) { m_log.DebugFormat( "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", @@ -703,7 +740,7 @@ namespace OpenSim.Region.ClientStack.Linden if (AddNewInventoryItem != null) { - AddNewInventoryItem(m_HostCapsObj.AgentID, item); + AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); } } -- cgit v1.1 From ead4b8998c07c4c5445b56fab955dfbdf0bf212f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 17:28:37 +0200 Subject: Revert "Remove the unused NewFileAgentInventoryVariablePrice module." It's actually used. This reverts commit 94a8e5572b1529190a174f29f866b65e7b2ccc0e. --- .../NewFileAgentInventoryVariablePriceModule.cs | 296 +++++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs new file mode 100644 index 0000000..52c4f44 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs @@ -0,0 +1,296 @@ +/* + * 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 System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.IO; +using System.Web; +using Mono.Addins; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OpenSim.Framework.Capabilities; + +namespace OpenSim.Region.ClientStack.Linden +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; +// private IAssetService m_assetService; + private bool m_dumpAssetsToFile = false; + private bool m_enabled = true; + private int m_levelUpload = 0; + + #region IRegionModuleBase Members + + + public Type ReplaceableInterface + { + get { return null; } + } + + public void Initialise(IConfigSource source) + { + IConfig meshConfig = source.Configs["Mesh"]; + if (meshConfig == null) + return; + + m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); + m_levelUpload = meshConfig.GetInt("LevelUpload", 0); + } + + public void AddRegion(Scene pScene) + { + m_scene = pScene; + } + + public void RemoveRegion(Scene scene) + { + + m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene = null; + } + + public void RegionLoaded(Scene scene) + { + +// m_assetService = m_scene.RequestModuleInterface(); + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + #endregion + + + #region IRegionModule Members + + + + public void Close() { } + + public string Name { get { return "NewFileAgentInventoryVariablePriceModule"; } } + + + public void RegisterCaps(UUID agentID, Caps caps) + { + if(!m_enabled) + return; + + UUID capID = UUID.Random(); + +// m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID); + caps.RegisterHandler( + "NewFileAgentInventoryVariablePrice", + new LLSDStreamhandler( + "POST", + "/CAPS/" + capID.ToString(), + req => NewAgentInventoryRequest(req, agentID), + "NewFileAgentInventoryVariablePrice", + agentID.ToString())); + } + + #endregion + + public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) + { + //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit + // you need to be aware of this + + //if (llsdRequest.asset_type == "texture" || + // llsdRequest.asset_type == "animation" || + // llsdRequest.asset_type == "sound") + // { + // check user level + + ScenePresence avatar = null; + IClientAPI client = null; + m_scene.TryGetScenePresence(agentID, out avatar); + + if (avatar != null) + { + client = avatar.ControllingClient; + + if (avatar.UserLevel < m_levelUpload) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); + + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + + // check funds + IMoneyModule mm = m_scene.RequestModuleInterface(); + + if (mm != null) + { + if (!mm.UploadCovered(agentID, mm.UploadCharge)) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + + // } + + string assetName = llsdRequest.name; + string assetDes = llsdRequest.description; + string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; + UUID newAsset = UUID.Random(); + UUID newInvItem = UUID.Random(); + UUID parentFolder = llsdRequest.folder_id; + string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; + + AssetUploader uploader = + new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); + + MainServer.Instance.AddStreamHandler( + new BinaryStreamHandler( + "POST", + capsBase + uploaderPath, + uploader.uploaderCaps, + "NewFileAgentInventoryVariablePrice", + agentID.ToString())); + + string protocol = "http://"; + + if (MainServer.Instance.UseSSL) + protocol = "https://"; + + string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + + uploaderPath; + + + LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + + uploadResponse.rsvp = uploaderURL; + uploadResponse.state = "upload"; + uploadResponse.resource_cost = 0; + uploadResponse.upload_price = 0; + + uploader.OnUpLoad += //UploadCompleteHandler; + + delegate( + string passetName, string passetDescription, UUID passetID, + UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, + string passetType) + { + UploadCompleteHandler(passetName, passetDescription, passetID, + pinventoryItem, pparentFolder, pdata, pinventoryType, + passetType,agentID); + }; + + return uploadResponse; + } + + public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, + UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, + string assetType,UUID AgentID) + { +// m_log.DebugFormat( +// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem); + + sbyte assType = 0; + sbyte inType = 0; + + if (inventoryType == "sound") + { + inType = 1; + assType = 1; + } + else if (inventoryType == "animation") + { + inType = 19; + assType = 20; + } + else if (inventoryType == "wearable") + { + inType = 18; + switch (assetType) + { + case "bodypart": + assType = 13; + break; + case "clothing": + assType = 5; + break; + } + } + else if (inventoryType == "mesh") + { + inType = (sbyte)InventoryType.Mesh; + assType = (sbyte)AssetType.Mesh; + } + + AssetBase asset; + asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); + asset.Data = data; + + if (m_scene.AssetService != null) + m_scene.AssetService.Store(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.Owner = AgentID; + item.CreatorId = AgentID.ToString(); + item.ID = inventoryItem; + item.AssetID = asset.FullID; + item.Description = assetDescription; + item.Name = assetName; + item.AssetType = assType; + item.InvType = inType; + item.Folder = parentFolder; + item.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + item.BasePermissions = (uint)PermissionMask.All; + item.EveryOnePermissions = 0; + item.NextPermissions = (uint)PermissionMask.All; + item.CreationDate = Util.UnixTimeSinceEpoch(); + m_scene.AddInventoryItem(item); + } + } +} -- cgit v1.1 From a6928a479eb84b14e949c5f589b9ce753edf457a Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 17:50:55 +0200 Subject: Add cost calculation suppor tto the VariablePrice one as well --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 1 - .../NewFileAgentInventoryVariablePriceModule.cs | 52 ++++++++++++++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 097e224..328dc75 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -417,7 +417,6 @@ namespace OpenSim.Region.ClientStack.Linden } } - /// /// /// diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs index 52c4f44..6e2b52d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs @@ -127,6 +127,37 @@ namespace OpenSim.Region.ClientStack.Linden #endregion + private delegate void UploadWithCostCompleteDelegate(string assetName, + string assetDescription, UUID assetID, UUID inventoryItem, + UUID parentFolder, byte[] data, string inventoryType, + string assetType, uint cost); + + private class AssetUploaderWithCost : AssetUploader + { + private uint m_cost; + + public event UploadWithCostCompleteDelegate OnUpLoad; + + public AssetUploaderWithCost(string assetName, string description, UUID assetID, + UUID inventoryItem, UUID parentFolderID, string invType, string assetType, + string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : + base(assetName, description, assetID, inventoryItem, parentFolderID, + invType, assetType, path, httpServer, dumpAssetsToFile) + { + m_cost = cost; + + base.OnUpLoad += UploadCompleteHandler; + } + + private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, + UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, + string assetType) + { + OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, + data, inventoryType, assetType, m_cost); + } + } + public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) { //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit @@ -138,6 +169,8 @@ namespace OpenSim.Region.ClientStack.Linden // { // check user level + uint cost = 0; + ScenePresence avatar = null; IClientAPI client = null; m_scene.TryGetScenePresence(agentID, out avatar); @@ -163,7 +196,10 @@ namespace OpenSim.Region.ClientStack.Linden if (mm != null) { - if (!mm.UploadCovered(agentID, mm.UploadCharge)) + // XPTO: Calculate cost here + cost = (uint)mm.UploadCharge; + + if (!mm.UploadCovered(agentID, (int)cost)) { if (client != null) client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); @@ -185,9 +221,9 @@ namespace OpenSim.Region.ClientStack.Linden UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; - AssetUploader uploader = - new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile); + AssetUploaderWithCost uploader = + new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile, cost); MainServer.Instance.AddStreamHandler( new BinaryStreamHandler( @@ -218,11 +254,11 @@ namespace OpenSim.Region.ClientStack.Linden delegate( string passetName, string passetDescription, UUID passetID, UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, - string passetType) + string passetType, uint cost) { UploadCompleteHandler(passetName, passetDescription, passetID, pinventoryItem, pparentFolder, pdata, pinventoryType, - passetType,agentID); + passetType,agentID, cost); }; return uploadResponse; @@ -230,7 +266,7 @@ namespace OpenSim.Region.ClientStack.Linden public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType,UUID AgentID) + string assetType,UUID AgentID, uint cost) { // m_log.DebugFormat( // "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem); @@ -290,7 +326,7 @@ namespace OpenSim.Region.ClientStack.Linden item.EveryOnePermissions = 0; item.NextPermissions = (uint)PermissionMask.All; item.CreationDate = Util.UnixTimeSinceEpoch(); - m_scene.AddInventoryItem(item); + m_scene.AddUploadedInventoryItem(AgentID, item, cost); } } } -- cgit v1.1 From 375ca478dd7bebd6825e6305ba7c8a44fe119c7e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 17:52:24 +0200 Subject: Rename NewFileAgentInventoryVariablePrice to NewAgentInventoryVariablePrice which is the name actually used in viewer code. --- .../NewFileAgentInventoryVariablePriceModule.cs | 332 --------------------- 1 file changed, 332 deletions(-) delete mode 100644 OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs deleted file mode 100644 index 6e2b52d..0000000 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ /dev/null @@ -1,332 +0,0 @@ -/* - * 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 System.Collections; -using System.Collections.Specialized; -using System.Reflection; -using System.IO; -using System.Web; -using Mono.Addins; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; -using Caps = OpenSim.Framework.Capabilities.Caps; -using OpenSim.Framework.Capabilities; - -namespace OpenSim.Region.ClientStack.Linden -{ - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Scene m_scene; -// private IAssetService m_assetService; - private bool m_dumpAssetsToFile = false; - private bool m_enabled = true; - private int m_levelUpload = 0; - - #region IRegionModuleBase Members - - - public Type ReplaceableInterface - { - get { return null; } - } - - public void Initialise(IConfigSource source) - { - IConfig meshConfig = source.Configs["Mesh"]; - if (meshConfig == null) - return; - - m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); - m_levelUpload = meshConfig.GetInt("LevelUpload", 0); - } - - public void AddRegion(Scene pScene) - { - m_scene = pScene; - } - - public void RemoveRegion(Scene scene) - { - - m_scene.EventManager.OnRegisterCaps -= RegisterCaps; - m_scene = null; - } - - public void RegionLoaded(Scene scene) - { - -// m_assetService = m_scene.RequestModuleInterface(); - m_scene.EventManager.OnRegisterCaps += RegisterCaps; - } - - #endregion - - - #region IRegionModule Members - - - - public void Close() { } - - public string Name { get { return "NewFileAgentInventoryVariablePriceModule"; } } - - - public void RegisterCaps(UUID agentID, Caps caps) - { - if(!m_enabled) - return; - - UUID capID = UUID.Random(); - -// m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID); - caps.RegisterHandler( - "NewFileAgentInventoryVariablePrice", - new LLSDStreamhandler( - "POST", - "/CAPS/" + capID.ToString(), - req => NewAgentInventoryRequest(req, agentID), - "NewFileAgentInventoryVariablePrice", - agentID.ToString())); - } - - #endregion - - private delegate void UploadWithCostCompleteDelegate(string assetName, - string assetDescription, UUID assetID, UUID inventoryItem, - UUID parentFolder, byte[] data, string inventoryType, - string assetType, uint cost); - - private class AssetUploaderWithCost : AssetUploader - { - private uint m_cost; - - public event UploadWithCostCompleteDelegate OnUpLoad; - - public AssetUploaderWithCost(string assetName, string description, UUID assetID, - UUID inventoryItem, UUID parentFolderID, string invType, string assetType, - string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : - base(assetName, description, assetID, inventoryItem, parentFolderID, - invType, assetType, path, httpServer, dumpAssetsToFile) - { - m_cost = cost; - - base.OnUpLoad += UploadCompleteHandler; - } - - private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType) - { - OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, - data, inventoryType, assetType, m_cost); - } - } - - public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) - { - //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit - // you need to be aware of this - - //if (llsdRequest.asset_type == "texture" || - // llsdRequest.asset_type == "animation" || - // llsdRequest.asset_type == "sound") - // { - // check user level - - uint cost = 0; - - ScenePresence avatar = null; - IClientAPI client = null; - m_scene.TryGetScenePresence(agentID, out avatar); - - if (avatar != null) - { - client = avatar.ControllingClient; - - if (avatar.UserLevel < m_levelUpload) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } - } - - // check funds - IMoneyModule mm = m_scene.RequestModuleInterface(); - - if (mm != null) - { - // XPTO: Calculate cost here - cost = (uint)mm.UploadCharge; - - if (!mm.UploadCovered(agentID, (int)cost)) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } - } - - // } - - string assetName = llsdRequest.name; - string assetDes = llsdRequest.description; - string capsBase = "/CAPS/NewFileAgentInventoryVariablePrice/"; - UUID newAsset = UUID.Random(); - UUID newInvItem = UUID.Random(); - UUID parentFolder = llsdRequest.folder_id; - string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; - - AssetUploaderWithCost uploader = - new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile, cost); - - MainServer.Instance.AddStreamHandler( - new BinaryStreamHandler( - "POST", - capsBase + uploaderPath, - uploader.uploaderCaps, - "NewFileAgentInventoryVariablePrice", - agentID.ToString())); - - string protocol = "http://"; - - if (MainServer.Instance.UseSSL) - protocol = "https://"; - - string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + - uploaderPath; - - - LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - - uploadResponse.rsvp = uploaderURL; - uploadResponse.state = "upload"; - uploadResponse.resource_cost = 0; - uploadResponse.upload_price = 0; - - uploader.OnUpLoad += //UploadCompleteHandler; - - delegate( - string passetName, string passetDescription, UUID passetID, - UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, - string passetType, uint cost) - { - UploadCompleteHandler(passetName, passetDescription, passetID, - pinventoryItem, pparentFolder, pdata, pinventoryType, - passetType,agentID, cost); - }; - - return uploadResponse; - } - - public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType,UUID AgentID, uint cost) - { -// m_log.DebugFormat( -// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem); - - sbyte assType = 0; - sbyte inType = 0; - - if (inventoryType == "sound") - { - inType = 1; - assType = 1; - } - else if (inventoryType == "animation") - { - inType = 19; - assType = 20; - } - else if (inventoryType == "wearable") - { - inType = 18; - switch (assetType) - { - case "bodypart": - assType = 13; - break; - case "clothing": - assType = 5; - break; - } - } - else if (inventoryType == "mesh") - { - inType = (sbyte)InventoryType.Mesh; - assType = (sbyte)AssetType.Mesh; - } - - AssetBase asset; - asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); - asset.Data = data; - - if (m_scene.AssetService != null) - m_scene.AssetService.Store(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.Owner = AgentID; - item.CreatorId = AgentID.ToString(); - item.ID = inventoryItem; - item.AssetID = asset.FullID; - item.Description = assetDescription; - item.Name = assetName; - item.AssetType = assType; - item.InvType = inType; - item.Folder = parentFolder; - item.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - item.BasePermissions = (uint)PermissionMask.All; - item.EveryOnePermissions = 0; - item.NextPermissions = (uint)PermissionMask.All; - item.CreationDate = Util.UnixTimeSinceEpoch(); - m_scene.AddUploadedInventoryItem(AgentID, item, cost); - } - } -} -- cgit v1.1 From 757a669924db1a68ed75640816c8b9d32a6146e1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 17:55:33 +0200 Subject: Re-add the module and fix a typo --- .../Caps/NewAgentInventoryVariablePriceModule.cs | 332 +++++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs new file mode 100644 index 0000000..423ad58 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs @@ -0,0 +1,332 @@ +/* + * 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 System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.IO; +using System.Web; +using Mono.Addins; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OpenSim.Framework.Capabilities; + +namespace OpenSim.Region.ClientStack.Linden +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class NewAgentInventoryVariablePriceModule : INonSharedRegionModule + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; +// private IAssetService m_assetService; + private bool m_dumpAssetsToFile = false; + private bool m_enabled = true; + private int m_levelUpload = 0; + + #region IRegionModuleBase Members + + + public Type ReplaceableInterface + { + get { return null; } + } + + public void Initialise(IConfigSource source) + { + IConfig meshConfig = source.Configs["Mesh"]; + if (meshConfig == null) + return; + + m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); + m_levelUpload = meshConfig.GetInt("LevelUpload", 0); + } + + public void AddRegion(Scene pScene) + { + m_scene = pScene; + } + + public void RemoveRegion(Scene scene) + { + + m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene = null; + } + + public void RegionLoaded(Scene scene) + { + +// m_assetService = m_scene.RequestModuleInterface(); + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + } + + #endregion + + + #region IRegionModule Members + + + + public void Close() { } + + public string Name { get { return "NewAgentInventoryVariablePriceModule"; } } + + + public void RegisterCaps(UUID agentID, Caps caps) + { + if(!m_enabled) + return; + + UUID capID = UUID.Random(); + +// m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID); + caps.RegisterHandler( + "NewAgentInventoryVariablePrice", + new LLSDStreamhandler( + "POST", + "/CAPS/" + capID.ToString(), + req => NewAgentInventoryRequest(req, agentID), + "NewAgentInventoryVariablePrice", + agentID.ToString())); + } + + #endregion + + private delegate void UploadWithCostCompleteDelegate(string assetName, + string assetDescription, UUID assetID, UUID inventoryItem, + UUID parentFolder, byte[] data, string inventoryType, + string assetType, uint cost); + + private class AssetUploaderWithCost : AssetUploader + { + private uint m_cost; + + public event UploadWithCostCompleteDelegate OnUpLoad; + + public AssetUploaderWithCost(string assetName, string description, UUID assetID, + UUID inventoryItem, UUID parentFolderID, string invType, string assetType, + string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : + base(assetName, description, assetID, inventoryItem, parentFolderID, + invType, assetType, path, httpServer, dumpAssetsToFile) + { + m_cost = cost; + + base.OnUpLoad += UploadCompleteHandler; + } + + private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, + UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, + string assetType) + { + OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, + data, inventoryType, assetType, m_cost); + } + } + + public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) + { + //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit + // you need to be aware of this + + //if (llsdRequest.asset_type == "texture" || + // llsdRequest.asset_type == "animation" || + // llsdRequest.asset_type == "sound") + // { + // check user level + + uint cost = 0; + + ScenePresence avatar = null; + IClientAPI client = null; + m_scene.TryGetScenePresence(agentID, out avatar); + + if (avatar != null) + { + client = avatar.ControllingClient; + + if (avatar.UserLevel < m_levelUpload) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); + + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + + // check funds + IMoneyModule mm = m_scene.RequestModuleInterface(); + + if (mm != null) + { + // XPTO: Calculate cost here + cost = (uint)mm.UploadCharge; + + if (!mm.UploadCovered(agentID, (int)cost)) + { + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + + LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + errorResponse.rsvp = ""; + errorResponse.state = "error"; + return errorResponse; + } + } + + // } + + string assetName = llsdRequest.name; + string assetDes = llsdRequest.description; + string capsBase = "/CAPS/NewAgentInventoryVariablePrice/"; + UUID newAsset = UUID.Random(); + UUID newInvItem = UUID.Random(); + UUID parentFolder = llsdRequest.folder_id; + string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; + + AssetUploaderWithCost uploader = + new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile, cost); + + MainServer.Instance.AddStreamHandler( + new BinaryStreamHandler( + "POST", + capsBase + uploaderPath, + uploader.uploaderCaps, + "NewAgentInventoryVariablePrice", + agentID.ToString())); + + string protocol = "http://"; + + if (MainServer.Instance.UseSSL) + protocol = "https://"; + + string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + + uploaderPath; + + + LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); + + uploadResponse.rsvp = uploaderURL; + uploadResponse.state = "upload"; + uploadResponse.resource_cost = 0; + uploadResponse.upload_price = 0; + + uploader.OnUpLoad += //UploadCompleteHandler; + + delegate( + string passetName, string passetDescription, UUID passetID, + UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, + string passetType, uint pcost) + { + UploadCompleteHandler(passetName, passetDescription, passetID, + pinventoryItem, pparentFolder, pdata, pinventoryType, + passetType,agentID, pcost); + }; + + return uploadResponse; + } + + public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, + UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, + string assetType,UUID AgentID, uint cost) + { +// m_log.DebugFormat( +// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem); + + sbyte assType = 0; + sbyte inType = 0; + + if (inventoryType == "sound") + { + inType = 1; + assType = 1; + } + else if (inventoryType == "animation") + { + inType = 19; + assType = 20; + } + else if (inventoryType == "wearable") + { + inType = 18; + switch (assetType) + { + case "bodypart": + assType = 13; + break; + case "clothing": + assType = 5; + break; + } + } + else if (inventoryType == "mesh") + { + inType = (sbyte)InventoryType.Mesh; + assType = (sbyte)AssetType.Mesh; + } + + AssetBase asset; + asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); + asset.Data = data; + + if (m_scene.AssetService != null) + m_scene.AssetService.Store(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.Owner = AgentID; + item.CreatorId = AgentID.ToString(); + item.ID = inventoryItem; + item.AssetID = asset.FullID; + item.Description = assetDescription; + item.Name = assetName; + item.AssetType = assType; + item.InvType = inType; + item.Folder = parentFolder; + item.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + item.BasePermissions = (uint)PermissionMask.All; + item.EveryOnePermissions = 0; + item.NextPermissions = (uint)PermissionMask.All; + item.CreationDate = Util.UnixTimeSinceEpoch(); + m_scene.AddUploadedInventoryItem(AgentID, item, cost); + } + } +} -- cgit v1.1 From 19b00a5b3ce27d3160648c6bc49699b09dc4f283 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 17:58:46 +0200 Subject: Removing the variable prica handler again. It's never called, was misnamed and probably never worked past the mesh beta. --- .../Caps/NewAgentInventoryVariablePriceModule.cs | 332 --------------------- 1 file changed, 332 deletions(-) delete mode 100644 OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs deleted file mode 100644 index 423ad58..0000000 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewAgentInventoryVariablePriceModule.cs +++ /dev/null @@ -1,332 +0,0 @@ -/* - * 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 System.Collections; -using System.Collections.Specialized; -using System.Reflection; -using System.IO; -using System.Web; -using Mono.Addins; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; -using Caps = OpenSim.Framework.Capabilities.Caps; -using OpenSim.Framework.Capabilities; - -namespace OpenSim.Region.ClientStack.Linden -{ - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class NewAgentInventoryVariablePriceModule : INonSharedRegionModule - { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Scene m_scene; -// private IAssetService m_assetService; - private bool m_dumpAssetsToFile = false; - private bool m_enabled = true; - private int m_levelUpload = 0; - - #region IRegionModuleBase Members - - - public Type ReplaceableInterface - { - get { return null; } - } - - public void Initialise(IConfigSource source) - { - IConfig meshConfig = source.Configs["Mesh"]; - if (meshConfig == null) - return; - - m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); - m_levelUpload = meshConfig.GetInt("LevelUpload", 0); - } - - public void AddRegion(Scene pScene) - { - m_scene = pScene; - } - - public void RemoveRegion(Scene scene) - { - - m_scene.EventManager.OnRegisterCaps -= RegisterCaps; - m_scene = null; - } - - public void RegionLoaded(Scene scene) - { - -// m_assetService = m_scene.RequestModuleInterface(); - m_scene.EventManager.OnRegisterCaps += RegisterCaps; - } - - #endregion - - - #region IRegionModule Members - - - - public void Close() { } - - public string Name { get { return "NewAgentInventoryVariablePriceModule"; } } - - - public void RegisterCaps(UUID agentID, Caps caps) - { - if(!m_enabled) - return; - - UUID capID = UUID.Random(); - -// m_log.Debug("[NEW FILE AGENT INVENTORY VARIABLE PRICE]: /CAPS/" + capID); - caps.RegisterHandler( - "NewAgentInventoryVariablePrice", - new LLSDStreamhandler( - "POST", - "/CAPS/" + capID.ToString(), - req => NewAgentInventoryRequest(req, agentID), - "NewAgentInventoryVariablePrice", - agentID.ToString())); - } - - #endregion - - private delegate void UploadWithCostCompleteDelegate(string assetName, - string assetDescription, UUID assetID, UUID inventoryItem, - UUID parentFolder, byte[] data, string inventoryType, - string assetType, uint cost); - - private class AssetUploaderWithCost : AssetUploader - { - private uint m_cost; - - public event UploadWithCostCompleteDelegate OnUpLoad; - - public AssetUploaderWithCost(string assetName, string description, UUID assetID, - UUID inventoryItem, UUID parentFolderID, string invType, string assetType, - string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : - base(assetName, description, assetID, inventoryItem, parentFolderID, - invType, assetType, path, httpServer, dumpAssetsToFile) - { - m_cost = cost; - - base.OnUpLoad += UploadCompleteHandler; - } - - private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType) - { - OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, - data, inventoryType, assetType, m_cost); - } - } - - public LLSDNewFileAngentInventoryVariablePriceReplyResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest, UUID agentID) - { - //TODO: The Mesh uploader uploads many types of content. If you're going to implement a Money based limit - // you need to be aware of this - - //if (llsdRequest.asset_type == "texture" || - // llsdRequest.asset_type == "animation" || - // llsdRequest.asset_type == "sound") - // { - // check user level - - uint cost = 0; - - ScenePresence avatar = null; - IClientAPI client = null; - m_scene.TryGetScenePresence(agentID, out avatar); - - if (avatar != null) - { - client = avatar.ControllingClient; - - if (avatar.UserLevel < m_levelUpload) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } - } - - // check funds - IMoneyModule mm = m_scene.RequestModuleInterface(); - - if (mm != null) - { - // XPTO: Calculate cost here - cost = (uint)mm.UploadCharge; - - if (!mm.UploadCovered(agentID, (int)cost)) - { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); - - LLSDNewFileAngentInventoryVariablePriceReplyResponse errorResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - errorResponse.rsvp = ""; - errorResponse.state = "error"; - return errorResponse; - } - } - - // } - - string assetName = llsdRequest.name; - string assetDes = llsdRequest.description; - string capsBase = "/CAPS/NewAgentInventoryVariablePrice/"; - UUID newAsset = UUID.Random(); - UUID newInvItem = UUID.Random(); - UUID parentFolder = llsdRequest.folder_id; - string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000") + "/"; - - AssetUploaderWithCost uploader = - new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, MainServer.Instance, m_dumpAssetsToFile, cost); - - MainServer.Instance.AddStreamHandler( - new BinaryStreamHandler( - "POST", - capsBase + uploaderPath, - uploader.uploaderCaps, - "NewAgentInventoryVariablePrice", - agentID.ToString())); - - string protocol = "http://"; - - if (MainServer.Instance.UseSSL) - protocol = "https://"; - - string uploaderURL = protocol + m_scene.RegionInfo.ExternalHostName + ":" + MainServer.Instance.Port.ToString() + capsBase + - uploaderPath; - - - LLSDNewFileAngentInventoryVariablePriceReplyResponse uploadResponse = new LLSDNewFileAngentInventoryVariablePriceReplyResponse(); - - uploadResponse.rsvp = uploaderURL; - uploadResponse.state = "upload"; - uploadResponse.resource_cost = 0; - uploadResponse.upload_price = 0; - - uploader.OnUpLoad += //UploadCompleteHandler; - - delegate( - string passetName, string passetDescription, UUID passetID, - UUID pinventoryItem, UUID pparentFolder, byte[] pdata, string pinventoryType, - string passetType, uint pcost) - { - UploadCompleteHandler(passetName, passetDescription, passetID, - pinventoryItem, pparentFolder, pdata, pinventoryType, - passetType,agentID, pcost); - }; - - return uploadResponse; - } - - public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType,UUID AgentID, uint cost) - { -// m_log.DebugFormat( -// "[NEW FILE AGENT INVENTORY VARIABLE PRICE MODULE]: Upload complete for {0}", inventoryItem); - - sbyte assType = 0; - sbyte inType = 0; - - if (inventoryType == "sound") - { - inType = 1; - assType = 1; - } - else if (inventoryType == "animation") - { - inType = 19; - assType = 20; - } - else if (inventoryType == "wearable") - { - inType = 18; - switch (assetType) - { - case "bodypart": - assType = 13; - break; - case "clothing": - assType = 5; - break; - } - } - else if (inventoryType == "mesh") - { - inType = (sbyte)InventoryType.Mesh; - assType = (sbyte)AssetType.Mesh; - } - - AssetBase asset; - asset = new AssetBase(assetID, assetName, assType, AgentID.ToString()); - asset.Data = data; - - if (m_scene.AssetService != null) - m_scene.AssetService.Store(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.Owner = AgentID; - item.CreatorId = AgentID.ToString(); - item.ID = inventoryItem; - item.AssetID = asset.FullID; - item.Description = assetDescription; - item.Name = assetName; - item.AssetType = assType; - item.InvType = inType; - item.Folder = parentFolder; - item.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - item.BasePermissions = (uint)PermissionMask.All; - item.EveryOnePermissions = 0; - item.NextPermissions = (uint)PermissionMask.All; - item.CreationDate = Util.UnixTimeSinceEpoch(); - m_scene.AddUploadedInventoryItem(AgentID, item, cost); - } - } -} -- cgit v1.1 From 245763b1b08d667aede3be7c092fa4c7200549c0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Sep 2012 20:30:30 +0100 Subject: let LLSDAssetUploadRequest include asset_resources information plus let NewAgentInventoryRequest know about mesh (does nothing with it still) --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 328dc75..df43991 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -431,6 +431,7 @@ namespace OpenSim.Region.ClientStack.Linden if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || + llsdRequest.asset_type == "mesh" || llsdRequest.asset_type == "sound") { ScenePresence avatar = null; -- cgit v1.1 From 013e94af5d45a7c99e46e01d9c5965a79ac1b231 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Sep 2012 23:06:29 +0100 Subject: report mesh upload costs ( fake values) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 48 +++++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index df43991..90ac8ce 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -463,7 +463,26 @@ namespace OpenSim.Region.ClientStack.Linden if (mm != null) { // XPTO: The cost should be calculated about here - cost = (uint)mm.UploadCharge; + + if (llsdRequest.asset_type == "mesh") + { + if (llsdRequest.asset_resources == null) + { + client.SendAgentAlertMessage("Unable to upload asset. missing information.", false); + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + } + + uint textures_cost = (uint)llsdRequest.asset_resources.texture_list.Array.Count; + textures_cost *= (uint)mm.UploadCharge; + + cost = textures_cost; + } + else + cost = (uint)mm.UploadCharge; if (!mm.UploadCovered(client.AgentId, (int)cost)) { @@ -486,9 +505,14 @@ namespace OpenSim.Region.ClientStack.Linden UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + uint uploadCost = cost; + // don't charge for meshs until we done them + if (llsdRequest.asset_type == "mesh") + uploadCost = 0; + AssetUploaderWithCost uploader = new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); + llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, uploadCost); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -506,11 +530,31 @@ namespace OpenSim.Region.ClientStack.Linden string uploaderURL = protocol + m_HostCapsObj.HostName + ":" + m_HostCapsObj.Port.ToString() + capsBase + uploaderPath; + LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; + uploadResponse.upload_price = (int)cost; + + // use fake values for now + if (llsdRequest.asset_type == "mesh") + { + uploadResponse.data = new LLSDAssetUploadResponseData(); + uploadResponse.data.model_streaming_cost = 1.0; + uploadResponse.data.simulation_cost = 1.5; + + uploadResponse.data.physics_cost = 2.0; + uploadResponse.data.resource_cost = 3.0; + uploadResponse.data.upload_price_breakdown.mesh_instance = 1; + uploadResponse.data.upload_price_breakdown.mesh_physics = 2; + uploadResponse.data.upload_price_breakdown.mesh_streaming = 3; + uploadResponse.data.upload_price_breakdown.texture = 5; + uploadResponse.data.upload_price_breakdown.model = 4; + } + uploader.OnUpLoad += UploadCompleteHandler; return uploadResponse; + } /// -- cgit v1.1 From fd1ee58f87dfbad96e89675bf5ab002d2d3a347f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 11 Sep 2012 22:52:11 +0200 Subject: Add a missing brace, remove a useless temp variable, enable charging. --- .../Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 90ac8ce..9982556 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -482,7 +482,9 @@ namespace OpenSim.Region.ClientStack.Linden cost = textures_cost; } else + { cost = (uint)mm.UploadCharge; + } if (!mm.UploadCovered(client.AgentId, (int)cost)) { @@ -505,14 +507,9 @@ namespace OpenSim.Region.ClientStack.Linden UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - uint uploadCost = cost; - // don't charge for meshs until we done them - if (llsdRequest.asset_type == "mesh") - uploadCost = 0; - AssetUploaderWithCost uploader = new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, uploadCost); + llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( -- cgit v1.1 From 5139db2638fcee945961ea8d5635def581b54a4d Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 12 Sep 2012 12:56:59 +0200 Subject: Add a timer to time out upload caps handlers that are not used. --- .../ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 9982556..c4a9a19 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -26,6 +26,7 @@ */ using System; +using System.Timers; using System.Collections; using System.Collections.Generic; using System.IO; @@ -1106,6 +1107,7 @@ namespace OpenSim.Region.ClientStack.Linden private string m_invType = String.Empty; private string m_assetType = String.Empty; + private Timer m_timeoutTimer = new Timer(); public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, @@ -1121,6 +1123,11 @@ namespace OpenSim.Region.ClientStack.Linden m_assetType = assetType; m_invType = invType; m_dumpAssetsToFile = dumpAssetsToFile; + + m_timeoutTimer.Elapsed += TimedOut; + m_timeoutTimer.Interval = 120000; + m_timeoutTimer.AutoReset = false; + m_timeoutTimer.Start(); } /// @@ -1163,6 +1170,11 @@ namespace OpenSim.Region.ClientStack.Linden return res; } + private void TimedOut(object sender, ElapsedEventArgs args) + { + httpListener.RemoveStreamHandler("POST", uploaderPath); + } + ///Left this in and commented in case there are unforseen issues //private void SaveAssetToFile(string filename, byte[] data) //{ -- cgit v1.1 From d8e9188908bd1f6ab505e5424f02071b44f0fab1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 12 Sep 2012 21:14:55 +0200 Subject: Stop expiry timer when upload is complete. Log if timeout is reached. --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index c4a9a19..116055a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1149,6 +1149,7 @@ namespace OpenSim.Region.ClientStack.Linden res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); httpListener.RemoveStreamHandler("POST", uploaderPath); + m_timeoutTimer.Stop(); // TODO: probably make this a better set of extensions here string extension = ".jp2"; @@ -1172,6 +1173,7 @@ namespace OpenSim.Region.ClientStack.Linden private void TimedOut(object sender, ElapsedEventArgs args) { + m_log.InfoFormat("[CAPS]: Removing URL and handler for timed out mesh upload"); httpListener.RemoveStreamHandler("POST", uploaderPath); } -- cgit v1.1 From e7932682a2405dab69cb6b4447dde952c2a5c080 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 12 Sep 2012 21:24:09 +0200 Subject: Add a logger so the prior commit will work --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 116055a..88957ff 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1093,6 +1093,9 @@ namespace OpenSim.Region.ClientStack.Linden public class AssetUploader { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public event UpLoadedAsset OnUpLoad; private UpLoadedAsset handlerUpLoad = null; -- cgit v1.1 From 45fe25de0d9636690114091565775d264a0ca96f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Sep 2012 00:14:39 +0200 Subject: Allow some more connections to try to ease lag. --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 88957ff..580c005 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -467,6 +467,8 @@ namespace OpenSim.Region.ClientStack.Linden if (llsdRequest.asset_type == "mesh") { + cost += 20; // Constant for now to test showing a price + if (llsdRequest.asset_resources == null) { client.SendAgentAlertMessage("Unable to upload asset. missing information.", false); @@ -480,7 +482,7 @@ namespace OpenSim.Region.ClientStack.Linden uint textures_cost = (uint)llsdRequest.asset_resources.texture_list.Array.Count; textures_cost *= (uint)mm.UploadCharge; - cost = textures_cost; + cost += textures_cost; } else { -- cgit v1.1 From 387e59ff7f60f2b12526eaacd93581f76abe26e1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Sep 2012 21:24:25 +0200 Subject: Revamp the HTTP textures handler to allow a maximum of four fetches at any time and to drop requests for avatars n longer in the scene --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 223 +++++++++++++++++---- 1 file changed, 179 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 5ae9cc3..5b125ea 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -27,18 +27,13 @@ using System; using System.Collections; -using System.Collections.Specialized; -using System.Drawing; -using System.Drawing.Imaging; +using System.Collections.Generic; using System.Reflection; -using System.IO; -using System.Web; +using System.Threading; using log4net; using Nini.Config; using Mono.Addins; using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; @@ -47,64 +42,73 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using Caps = OpenSim.Framework.Capabilities.Caps; using OpenSim.Capabilities.Handlers; +using OpenSim.Framework.Monitoring; namespace OpenSim.Region.ClientStack.Linden { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + /// + /// This module implements both WebFetchTextureDescendents and FetchTextureDescendents2 capabilities. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetTextureModule")] public class GetTextureModule : INonSharedRegionModule { -// private static readonly ILog m_log = -// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; - private IAssetService m_assetService; - private bool m_Enabled = false; + private static GetTextureHandler m_getTextureHandler; + + private IAssetService m_assetService = null; - // TODO: Change this to a config option - const string REDIRECT_URL = null; + private Dictionary m_capsDict = new Dictionary(); + private static Thread[] m_workerThreads = null; - private string m_URL; + private static OpenMetaverse.BlockingQueue m_queue = + new OpenMetaverse.BlockingQueue(); #region ISharedRegionModule Members public void Initialise(IConfigSource source) { - IConfig config = source.Configs["ClientStack.LindenCaps"]; - if (config == null) - return; - - m_URL = config.GetString("Cap_GetTexture", string.Empty); - // Cap doesn't exist - if (m_URL != string.Empty) - m_Enabled = true; } public void AddRegion(Scene s) { - if (!m_Enabled) - return; - m_scene = s; + m_assetService = s.AssetService; } public void RemoveRegion(Scene s) { - if (!m_Enabled) - return; - m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; m_scene = null; } public void RegionLoaded(Scene s) { - if (!m_Enabled) - return; + // We'll reuse the same handler for all requests. + m_getTextureHandler = new GetTextureHandler(m_assetService); - m_assetService = m_scene.RequestModuleInterface(); m_scene.EventManager.OnRegisterCaps += RegisterCaps; + m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; + + if (m_workerThreads == null) + { + m_workerThreads = new Thread[4]; + + for (uint i = 0; i < 4; i++) + { + m_workerThreads[i] = Watchdog.StartThread(DoTextureRequests, + String.Format("TextureWorkerThread{0}", i), + ThreadPriority.Normal, + false, + true, + null, + int.MaxValue); + } + } } public void PostInitialise() @@ -122,24 +126,155 @@ namespace OpenSim.Region.ClientStack.Linden #endregion - public void RegisterCaps(UUID agentID, Caps caps) + ~GetTextureModule() + { + foreach (Thread t in m_workerThreads) + t.Abort(); + } + + private class PollServiceTextureEventArgs : PollServiceEventArgs { - UUID capID = UUID.Random(); + private List requests = + new List(); + private Dictionary responses = + new Dictionary(); + + private Scene m_scene; - //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); - if (m_URL == "localhost") + public PollServiceTextureEventArgs(UUID pId, Scene scene) : + base(null, null, null, null, pId, 30000) { -// m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); - caps.RegisterHandler( - "GetTexture", - new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString())); + m_scene = scene; + + HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; + GetEvents = (x, y, s) => + { + try + { + return this.responses[x]; + } + finally + { + responses.Remove(x); + } + }; + + Request = (x, y) => + { + y["RequestID"] = x.ToString(); + lock (this.requests) + this.requests.Add(y); + + m_queue.Enqueue(this); + }; + + NoEvents = (x, y) => + { + lock (this.requests) + { + Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); + requests.Remove(request); + } + + Hashtable response = new Hashtable(); + + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + return response; + }; } - else + + public void Process() { -// m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); - caps.RegisterHandler("GetTexture", m_URL); + Hashtable response; + Hashtable request = null; + + try + { + lock (this.requests) + { + request = requests[0]; + requests.RemoveAt(0); + } + } + catch + { + return; + } + + UUID requestID = new UUID(request["RequestID"].ToString()); + + // If the avatar is gone, don't bother to get the texture + if (m_scene.GetScenePresence(Id) == null) + { + response = new Hashtable(); + + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + responses[requestID] = response; + return; + } + + response = m_getTextureHandler.Handle(request); + + responses[requestID] = response; + } + } + + private void RegisterCaps(UUID agentID, Caps caps) + { + string capUrl = "/CAPS/" + UUID.Random() + "/"; + + // Register this as a poll service + // absurd large timeout to tune later to make a bit less than viewer + PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene); + + args.Type = PollServiceEventArgs.EventType.Texture; + MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); + + string hostName = m_scene.RegionInfo.ExternalHostName; + uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; + string protocol = "http"; + + if (MainServer.Instance.UseSSL) + { + hostName = MainServer.Instance.SSLCommonName; + port = MainServer.Instance.SSLPort; + protocol = "https"; } + caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); + + m_capsDict[agentID] = capUrl; } + private void DeregisterCaps(UUID agentID, Caps caps) + { + string capUrl; + + if (m_capsDict.TryGetValue(agentID, out capUrl)) + { + MainServer.Instance.RemoveHTTPHandler("", capUrl); + m_capsDict.Remove(agentID); + } + } + + private void DoTextureRequests() + { + while (true) + { + PollServiceTextureEventArgs args = m_queue.Dequeue(); + + args.Process(); + } + } } + } -- cgit v1.1 From 5bbc4fb2a5e0f357e0c880a722617d4f2b655203 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 13:39:38 +0100 Subject: missing file for suport of mesh upload cost --- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 596 +++++++++++++++++++++ 1 file changed, 596 insertions(+) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs new file mode 100644 index 0000000..8adacab --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -0,0 +1,596 @@ +// Proprietary code of Avination Virtual Limited +// (c) 2012 Melanie Thielker, Leal Duarte +// + +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +using OpenSim.Framework; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Framework.Capabilities; + +using ComponentAce.Compression.Libs.zlib; + +using OSDArray = OpenMetaverse.StructuredData.OSDArray; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; + +namespace OpenSim.Region.ClientStack.Linden +{ + public class ModelCost + { + float ModelMinCost = 5.0f; // try to favor small meshs versus sculpts + + // scale prices relative to basic cost + const float ModelCostScale = 1.0f; + + const float primCreationCost = 0.01f; // 256 prims cost extra 2.56 + + // weigthed size to money convertion + const float bytecost = 1e-4f; + + // for mesh upload fees based on compressed data sizes + // not using streaming physics and server costs as SL apparently does ?? + + const float medSizeWth = 1f; // 2x + const float lowSizeWth = 1.5f; // 2.5x + const float lowestSizeWth = 2f; // 3x + // favor potencial optimized meshs versus automatic decomposition + const float physMeshSizeWth = 6f; // counts 7x + const float physHullSizeWth = 8f; // counts 9x + + // price compression to promote complex meshs + const float feeCompressionBase = 50.0f; // transition from linear to log cost + const float feeCompressionScale = 250.0f; // 10000 scales to 1000 + + // stream cost size factors + const float highLodFactor = 17.36f; + const float midLodFactor = 277.78f; + const float lowLodFactor = 1111.11f; + + const int bytesPerCoord = 6; // 3 coords, 2 bytes per each + + private class ameshCostParam + { + public int highLODSize; + public int medLODSize; + public int lowLODSize; + public int lowestLODSize; + public float costFee; + public float physicsCost; + } + + public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, LLSDAssetUploadResponseData meshcostdata, out string error) + { + totalcost = 0; + error = string.Empty; + + if (resources == null || + resources.instance_list == null || + resources.instance_list.Array.Count == 0) + { + error = "Unable to upload mesh model. missing information."; + return false; + } + + meshcostdata.model_streaming_cost = 0.0; + meshcostdata.simulation_cost = 0.0; + meshcostdata.physics_cost = 0.0; + meshcostdata.resource_cost = 0.0; + + meshcostdata.upload_price_breakdown.mesh_instance = 0; + meshcostdata.upload_price_breakdown.mesh_physics = 0; + meshcostdata.upload_price_breakdown.mesh_streaming = 0; + meshcostdata.upload_price_breakdown.model = 0; + + int itmp; + + // textures cost + if (resources.texture_list != null && resources.texture_list.Array.Count > 0) + { + int textures_cost = resources.texture_list.Array.Count; + textures_cost *= basicCost; + + meshcostdata.upload_price_breakdown.texture = textures_cost; + totalcost += textures_cost; + } + + float meshsfee = 0; + + // meshs assets cost + + int numberMeshs = 0; + List meshsCosts = new List(); + // a model could have no mesh actually + if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) + { + numberMeshs = resources.mesh_list.Array.Count; + + for (int i = 0; i < numberMeshs; i++) + { + ameshCostParam curCost = new ameshCostParam(); + byte[] data = (byte[])resources.mesh_list.Array[i]; + + if (!MeshCost(data, curCost, out error)) + { + return false; + } + meshsCosts.Add(curCost); + meshsfee += curCost.costFee; + } + } + + // instances (prims) cost + int numberInstances = resources.instance_list.Array.Count; + int mesh; + for (int i = 0; i < numberInstances; i++) + { + Hashtable inst = (Hashtable)resources.instance_list.Array[i]; + + // streamming cost + // assume all instances have a mesh + // but in general they can have normal prims + // but for now that seems not suported + // when they do, we will need to inspect pbs information + // and have cost funtions for all prims types + // don't check for shape type none, since + // that could be used to upload meshs with low cost + // changing later inworld + + ArrayList ascale = (ArrayList)inst["scale"]; + Vector3 scale; + double tmp; + tmp = (double)ascale[0]; + scale.X = (float)tmp; + tmp = (double)ascale[1]; + scale.Y = (float)tmp; + tmp = (double)ascale[2]; + scale.Z = (float)tmp; + + float sqdiam = scale.LengthSquared(); + + mesh = (int)inst["mesh"]; + + if(mesh >= numberMeshs) + { + error = "Unable to upload mesh model. incoerent information."; + return false; + } + + ameshCostParam curCost = meshsCosts[mesh]; + float mesh_streaming = streamingCost(curCost, sqdiam); + + meshcostdata.model_streaming_cost += mesh_streaming; + + meshcostdata.physics_cost += curCost.physicsCost; + + // unscripted and static prim server cost + meshcostdata.simulation_cost += 0.5f; + // charge for prims creation + meshsfee += primCreationCost; + } + + if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) + meshcostdata.resource_cost = meshcostdata.model_streaming_cost; + else + meshcostdata.resource_cost = meshcostdata.physics_cost; + + if (meshsfee < ModelMinCost) + meshsfee = ModelMinCost; + + meshsfee *= ModelCostScale; + meshsfee += 0.5f; // rounding + + totalcost += (int)meshsfee; + + // breakdown prices + // don't seem to be in use so removed code for now + + return true; + } + + private bool MeshCost(byte[] data, ameshCostParam cost, out string error) + { + cost.highLODSize = 0; + cost.medLODSize = 0; + cost.lowLODSize = 0; + cost.lowestLODSize = 0; + cost.physicsCost = 0.0f; + cost.costFee = 0.0f; + + error = string.Empty; + + if (data == null || data.Length == 0) + { + error = "Unable to upload mesh model. missing information."; + return false; + } + + OSD meshOsd = null; + int start = 0; + + error = "Unable to upload mesh model. Invalid data"; + + using (MemoryStream ms = new MemoryStream(data)) + { + try + { + OSD osd = OSDParser.DeserializeLLSDBinary(ms); + if (osd is OSDMap) + meshOsd = (OSDMap)osd; + else + return false; + } + catch (Exception e) + { + return false; + } + start = (int)ms.Position; + } + + OSDMap map = (OSDMap)meshOsd; + OSDMap tmpmap; + + int highlod_size = 0; + int medlod_size = 0; + int lowlod_size = 0; + int lowestlod_size = 0; + int skin_size = 0; + + int hulls_size = 0; + int phys_nhulls; + int phys_hullsvertices = 0; + + int physmesh_size = 0; + int phys_ntriangles = 0; + + int submesh_offset = -1; + + if (map.ContainsKey("physics_convex")) + { + tmpmap = (OSDMap)map["physics_convex"]; + if (tmpmap.ContainsKey("offset")) + submesh_offset = tmpmap["offset"].AsInteger() + start; + if (tmpmap.ContainsKey("size")) + hulls_size = tmpmap["size"].AsInteger(); + } + + if (submesh_offset < 0 || hulls_size == 0) + { + error = "Unable to upload mesh model. missing physics_convex block"; + return false; + } + + if (!hulls(data, submesh_offset, hulls_size, out phys_hullsvertices, out phys_nhulls)) + { + error = "Unable to upload mesh model. bad physics_convex block"; + return false; + } + + submesh_offset = -1; + + // only look for LOD meshs sizes + + if (map.ContainsKey("high_lod")) + { + tmpmap = (OSDMap)map["high_lod"]; + // see at least if there is a offset for this one + if (tmpmap.ContainsKey("offset")) + submesh_offset = tmpmap["offset"].AsInteger() + start; + if (tmpmap.ContainsKey("size")) + highlod_size = tmpmap["size"].AsInteger(); + } + + if (submesh_offset < 0 || highlod_size <= 0) + { + error = "Unable to upload mesh model. missing high_lod"; + return false; + } + + bool haveprev = true; + + if (map.ContainsKey("medium_lod")) + { + tmpmap = (OSDMap)map["medium_lod"]; + if (tmpmap.ContainsKey("size")) + medlod_size = tmpmap["size"].AsInteger(); + else + haveprev = false; + } + + if (haveprev && map.ContainsKey("low_lod")) + { + tmpmap = (OSDMap)map["low_lod"]; + if (tmpmap.ContainsKey("size")) + lowlod_size = tmpmap["size"].AsInteger(); + else + haveprev = false; + } + + if (haveprev && map.ContainsKey("lowest_lod")) + { + tmpmap = (OSDMap)map["lowest_lod"]; + if (tmpmap.ContainsKey("size")) + lowestlod_size = tmpmap["size"].AsInteger(); + } + + if (map.ContainsKey("skin")) + { + tmpmap = (OSDMap)map["skin"]; + if (tmpmap.ContainsKey("size")) + skin_size = tmpmap["size"].AsInteger(); + } + + cost.highLODSize = highlod_size; + cost.medLODSize = medlod_size; + cost.lowLODSize = lowlod_size; + cost.lowestLODSize = lowestlod_size; + + submesh_offset = -1; + + if (map.ContainsKey("physics_mesh")) + { + tmpmap = (OSDMap)map["physics_mesh"]; + if (tmpmap.ContainsKey("offset")) + submesh_offset = tmpmap["offset"].AsInteger() + start; + if (tmpmap.ContainsKey("size")) + physmesh_size = tmpmap["size"].AsInteger(); + + if (submesh_offset >= 0 || physmesh_size > 0) + { + + if (!submesh(data, submesh_offset, physmesh_size, out phys_ntriangles)) + { + error = "Unable to upload mesh model. parsing error"; + return false; + } + } + } + + // upload is done in convex shape type so only one hull + phys_hullsvertices++; + cost.physicsCost = 0.04f * phys_hullsvertices; + + float sfee; + + sfee = data.Length; // start with total compressed data size + + // penalize lod meshs that should be more builder optimized + sfee += medSizeWth * medlod_size; + sfee += lowSizeWth * lowlod_size; + sfee += lowestSizeWth * lowlod_size; + + // physics + // favor potencial optimized meshs versus automatic decomposition + if (physmesh_size != 0) + sfee += physMeshSizeWth * (physmesh_size + hulls_size / 4); // reduce cost of mandatory convex hull + else + sfee += physHullSizeWth * hulls_size; + + // bytes to money + sfee *= bytecost; + + // fee compression + if (sfee > feeCompressionBase) + { + sfee -= feeCompressionBase; + sfee = feeCompressionScale * (float)Math.Log10((double)sfee); + sfee += feeCompressionBase; + } + + + + cost.costFee = sfee; + return true; + } + + private bool submesh(byte[] data, int offset, int size, out int ntriangles) + { + ntriangles = 0; + + OSD decodedMeshOsd = new OSD(); + byte[] meshBytes = new byte[size]; + System.Buffer.BlockCopy(data, offset, meshBytes, 0, size); + try + { + using (MemoryStream inMs = new MemoryStream(meshBytes)) + { + using (MemoryStream outMs = new MemoryStream()) + { + using (ZOutputStream zOut = new ZOutputStream(outMs)) + { + byte[] readBuffer = new byte[4096]; + int readLen = 0; + while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0) + { + zOut.Write(readBuffer, 0, readLen); + } + zOut.Flush(); + outMs.Seek(0, SeekOrigin.Begin); + + byte[] decompressedBuf = outMs.GetBuffer(); + decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); + } + } + } + } + catch (Exception e) + { + return false; + } + + OSDArray decodedMeshOsdArray = null; + if ((!decodedMeshOsd is OSDArray)) + return false; + + byte[] dummy; + + decodedMeshOsdArray = (OSDArray)decodedMeshOsd; + foreach (OSD subMeshOsd in decodedMeshOsdArray) + { + if (subMeshOsd is OSDMap) + { + OSDMap subtmpmap = (OSDMap)subMeshOsd; + if (subtmpmap.ContainsKey("NoGeometry") && ((OSDBoolean)subtmpmap["NoGeometry"])) + continue; + + if (!subtmpmap.ContainsKey("Position")) + return false; + + if (subtmpmap.ContainsKey("TriangleList")) + { + dummy = subtmpmap["TriangleList"].AsBinary(); + ntriangles += dummy.Length / bytesPerCoord; + } + else + return false; + } + } + + return true; + } + + private bool hulls(byte[] data, int offset, int size, out int nvertices, out int nhulls) + { + nvertices = 0; + nhulls = 1; + + OSD decodedMeshOsd = new OSD(); + byte[] meshBytes = new byte[size]; + System.Buffer.BlockCopy(data, offset, meshBytes, 0, size); + try + { + using (MemoryStream inMs = new MemoryStream(meshBytes)) + { + using (MemoryStream outMs = new MemoryStream()) + { + using (ZOutputStream zOut = new ZOutputStream(outMs)) + { + byte[] readBuffer = new byte[4096]; + int readLen = 0; + while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0) + { + zOut.Write(readBuffer, 0, readLen); + } + zOut.Flush(); + outMs.Seek(0, SeekOrigin.Begin); + + byte[] decompressedBuf = outMs.GetBuffer(); + decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); + } + } + } + } + catch (Exception e) + { + return false; + } + + OSDMap cmap = (OSDMap)decodedMeshOsd; + if (cmap == null) + return false; + + byte[] dummy; + + // must have one of this + if (cmap.ContainsKey("BoundingVerts")) + { + dummy = cmap["BoundingVerts"].AsBinary(); + nvertices = dummy.Length / bytesPerCoord; + } + else + return false; + +/* upload is done with convex shape type + if (cmap.ContainsKey("HullList")) + { + dummy = cmap["HullList"].AsBinary(); + nhulls += dummy.Length; + } + + + if (cmap.ContainsKey("Positions")) + { + dummy = cmap["Positions"].AsBinary(); + nvertices = dummy.Length / bytesPerCoord; + } + */ + + return true; + } + + private float streamingCost(ameshCostParam curCost, float sqdiam) + { + // compute efective areas + float ma = 262144f; + + float mh = sqdiam * highLodFactor; + if (mh > ma) + mh = ma; + float mm = sqdiam * midLodFactor; + if (mm > ma) + mm = ma; + + float ml = sqdiam * lowLodFactor; + if (ml > ma) + ml = ma; + + float mlst = ma; + + mlst -= ml; + ml -= mm; + mm -= mh; + + if (mlst < 1.0f) + mlst = 1.0f; + if (ml < 1.0f) + ml = 1.0f; + if (mm < 1.0f) + mm = 1.0f; + if (mh < 1.0f) + mh = 1.0f; + + ma = mlst + ml + mm + mh; + + // get LODs compressed sizes + // giving 384 bytes bonus + int lst = curCost.lowestLODSize - 384; + int l = curCost.lowLODSize - 384; + int m = curCost.medLODSize - 384; + int h = curCost.highLODSize - 384; + + // use previus higher LOD size on missing ones + if (m <= 0) + m = h; + if (l <= 0) + l = m; + if (lst <= 0) + lst = l; + + // force minumum sizes + if (lst < 16) + lst = 16; + if (l < 16) + l = 16; + if (m < 16) + m = 16; + if (h < 16) + h = 16; + + // compute cost weighted by relative effective areas + + float cost = (float)lst * mlst + (float)l * ml + (float)m * mm + (float)h * mh; + cost /= ma; + + cost *= 0.004f; // overall tunning parameter + + return cost; + } + } +} -- cgit v1.1 From 5915dfc26f0fe02411588ddea2791d69cb67d1ed Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 15:37:05 +0100 Subject: Make use of mesh cost functions --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 29 ++++++++-------------- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 8 +++--- 2 files changed, 13 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 580c005..ce3ca8b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -429,6 +429,7 @@ namespace OpenSim.Region.ClientStack.Linden //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); uint cost = 0; + LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || @@ -467,11 +468,15 @@ namespace OpenSim.Region.ClientStack.Linden if (llsdRequest.asset_type == "mesh") { - cost += 20; // Constant for now to test showing a price + string error; + int modelcost; + ModelCost mc = new ModelCost(); - if (llsdRequest.asset_resources == null) + if (!mc.MeshModelCost(llsdRequest.asset_resources, mm.UploadCharge, out modelcost, + meshcostdata, out error)) { - client.SendAgentAlertMessage("Unable to upload asset. missing information.", false); + + client.SendAgentAlertMessage(error, false); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; @@ -479,10 +484,7 @@ namespace OpenSim.Region.ClientStack.Linden return errorResponse; } - uint textures_cost = (uint)llsdRequest.asset_resources.texture_list.Array.Count; - textures_cost *= (uint)mm.UploadCharge; - - cost += textures_cost; + cost = (uint)modelcost; } else { @@ -536,20 +538,9 @@ namespace OpenSim.Region.ClientStack.Linden uploadResponse.state = "upload"; uploadResponse.upload_price = (int)cost; - // use fake values for now if (llsdRequest.asset_type == "mesh") { - uploadResponse.data = new LLSDAssetUploadResponseData(); - uploadResponse.data.model_streaming_cost = 1.0; - uploadResponse.data.simulation_cost = 1.5; - - uploadResponse.data.physics_cost = 2.0; - uploadResponse.data.resource_cost = 3.0; - uploadResponse.data.upload_price_breakdown.mesh_instance = 1; - uploadResponse.data.upload_price_breakdown.mesh_physics = 2; - uploadResponse.data.upload_price_breakdown.mesh_streaming = 3; - uploadResponse.data.upload_price_breakdown.texture = 5; - uploadResponse.data.upload_price_breakdown.model = 4; + uploadResponse.data = meshcostdata; } uploader.OnUpLoad += UploadCompleteHandler; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 8adacab..0b5d3fa 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -27,9 +27,6 @@ namespace OpenSim.Region.ClientStack.Linden { float ModelMinCost = 5.0f; // try to favor small meshs versus sculpts - // scale prices relative to basic cost - const float ModelCostScale = 1.0f; - const float primCreationCost = 0.01f; // 256 prims cost extra 2.56 // weigthed size to money convertion @@ -70,7 +67,7 @@ namespace OpenSim.Region.ClientStack.Linden { totalcost = 0; error = string.Empty; - + if (resources == null || resources.instance_list == null || resources.instance_list.Array.Count == 0) @@ -184,7 +181,8 @@ namespace OpenSim.Region.ClientStack.Linden if (meshsfee < ModelMinCost) meshsfee = ModelMinCost; - meshsfee *= ModelCostScale; + // scale cost with basic cost changes relative to 10 + meshsfee *= (float)basicCost / 10.0f; meshsfee += 0.5f; // rounding totalcost += (int)meshsfee; -- cgit v1.1 From df77724bbc30ab03f95508bd1b2f4539ed1206e3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 15:50:59 +0100 Subject: let mesh model estimator work even without money module, so other estimations can work --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ce3ca8b..ddb69c4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -462,35 +462,35 @@ namespace OpenSim.Region.ClientStack.Linden { IMoneyModule mm = m_Scene.RequestModuleInterface(); + int baseCost = 0; if (mm != null) + baseCost = mm.UploadCharge; + + if (llsdRequest.asset_type == "mesh") { - // XPTO: The cost should be calculated about here + string error; + int modelcost; + ModelCost mc = new ModelCost(); - if (llsdRequest.asset_type == "mesh") + if (!mc.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, + meshcostdata, out error)) { - string error; - int modelcost; - ModelCost mc = new ModelCost(); - - if (!mc.MeshModelCost(llsdRequest.asset_resources, mm.UploadCharge, out modelcost, - meshcostdata, out error)) - { - - client.SendAgentAlertMessage(error, false); + client.SendAgentAlertMessage(error, false); - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; - errorResponse.state = "error"; - return errorResponse; - } - - cost = (uint)modelcost; - } - else - { - cost = (uint)mm.UploadCharge; + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; } + cost = (uint)modelcost; + } + else + { + cost = (uint)baseCost; + } + if (mm != null) + { if (!mm.UploadCovered(client.AgentId, (int)cost)) { client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); -- cgit v1.1 From 1740325392f9771e629ca290a608f26df85fb169 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 17:49:10 +0100 Subject: removed broken fee compression --- .../ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 0b5d3fa..622a2d9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -42,10 +42,6 @@ namespace OpenSim.Region.ClientStack.Linden const float physMeshSizeWth = 6f; // counts 7x const float physHullSizeWth = 8f; // counts 9x - // price compression to promote complex meshs - const float feeCompressionBase = 50.0f; // transition from linear to log cost - const float feeCompressionScale = 250.0f; // 10000 scales to 1000 - // stream cost size factors const float highLodFactor = 17.36f; const float midLodFactor = 277.78f; @@ -373,17 +369,7 @@ namespace OpenSim.Region.ClientStack.Linden // bytes to money sfee *= bytecost; - - // fee compression - if (sfee > feeCompressionBase) - { - sfee -= feeCompressionBase; - sfee = feeCompressionScale * (float)Math.Log10((double)sfee); - sfee += feeCompressionBase; - } - - - + cost.costFee = sfee; return true; } -- cgit v1.1 From 7f5b1182efab9e7a80293622fa658d8d1a7b1fc8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 19:09:51 +0100 Subject: same cleanup --- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 79 +++++++++++----------- 1 file changed, 41 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 622a2d9..ba73a25 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.ClientStack.Linden const float physMeshSizeWth = 6f; // counts 7x const float physHullSizeWth = 8f; // counts 9x - // stream cost size factors + // stream cost area factors const float highLodFactor = 17.36f; const float midLodFactor = 277.78f; const float lowLodFactor = 1111.11f; @@ -94,13 +94,12 @@ namespace OpenSim.Region.ClientStack.Linden totalcost += textures_cost; } - float meshsfee = 0; - // meshs assets cost - + float meshsfee = 0; int numberMeshs = 0; + bool haveMeshs = false; List meshsCosts = new List(); - // a model could have no mesh actually + if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) { numberMeshs = resources.mesh_list.Array.Count; @@ -117,6 +116,7 @@ namespace OpenSim.Region.ClientStack.Linden meshsCosts.Add(curCost); meshsfee += curCost.costFee; } + haveMeshs = true; } // instances (prims) cost @@ -126,44 +126,43 @@ namespace OpenSim.Region.ClientStack.Linden { Hashtable inst = (Hashtable)resources.instance_list.Array[i]; - // streamming cost - // assume all instances have a mesh - // but in general they can have normal prims - // but for now that seems not suported - // when they do, we will need to inspect pbs information - // and have cost funtions for all prims types - // don't check for shape type none, since - // that could be used to upload meshs with low cost - // changing later inworld - - ArrayList ascale = (ArrayList)inst["scale"]; - Vector3 scale; - double tmp; - tmp = (double)ascale[0]; - scale.X = (float)tmp; - tmp = (double)ascale[1]; - scale.Y = (float)tmp; - tmp = (double)ascale[2]; - scale.Z = (float)tmp; - - float sqdiam = scale.LengthSquared(); - - mesh = (int)inst["mesh"]; - - if(mesh >= numberMeshs) + if (haveMeshs && inst.ContainsKey("mesh")) { - error = "Unable to upload mesh model. incoerent information."; - return false; - } + mesh = (int)inst["mesh"]; - ameshCostParam curCost = meshsCosts[mesh]; - float mesh_streaming = streamingCost(curCost, sqdiam); + if (mesh >= numberMeshs) + { + error = "Unable to upload mesh model. incoerent information."; + return false; + } + + // streamming cost + ArrayList ascale = (ArrayList)inst["scale"]; + Vector3 scale; + double tmp; + tmp = (double)ascale[0]; + scale.X = (float)tmp; + tmp = (double)ascale[1]; + scale.Y = (float)tmp; + tmp = (double)ascale[2]; + scale.Z = (float)tmp; - meshcostdata.model_streaming_cost += mesh_streaming; + float sqdiam = scale.LengthSquared(); - meshcostdata.physics_cost += curCost.physicsCost; + ameshCostParam curCost = meshsCosts[mesh]; + float mesh_streaming = streamingCost(curCost, sqdiam); + + meshcostdata.model_streaming_cost += mesh_streaming; + meshcostdata.physics_cost += curCost.physicsCost; + } + else // instance as no mesh ?? + { + // to do later if needed + meshcostdata.model_streaming_cost += 0.5f; + meshcostdata.physics_cost += 1.0f; + } - // unscripted and static prim server cost + // assume unscripted and static prim server cost meshcostdata.simulation_cost += 0.5f; // charge for prims creation meshsfee += primCreationCost; @@ -174,6 +173,10 @@ namespace OpenSim.Region.ClientStack.Linden else meshcostdata.resource_cost = meshcostdata.physics_cost; + if (meshcostdata.resource_cost < meshcostdata.simulation_cost) + meshcostdata.resource_cost = meshcostdata.simulation_cost; + + if (meshsfee < ModelMinCost) meshsfee = ModelMinCost; -- cgit v1.1 From c3666c9ec3f0e32443094fbcb683dec7b457a3e6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 19:38:05 +0100 Subject: make sure client still has money at upload --- .../ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ddb69c4..4ba8254 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -489,6 +489,7 @@ namespace OpenSim.Region.ClientStack.Linden cost = (uint)baseCost; } + // check funds if (mm != null) { if (!mm.UploadCovered(client.AgentId, (int)cost)) @@ -565,6 +566,21 @@ namespace OpenSim.Region.ClientStack.Linden sbyte assType = 0; sbyte inType = 0; + IClientAPI client = null; + + IMoneyModule mm = m_Scene.RequestModuleInterface(); + if (mm != null) + { + // make sure client still has enougth credit + if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost)) + { + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + return; + } + } + if (inventoryType == "sound") { inType = 1; -- cgit v1.1 From c1eec3b82818f91f66580cecc32c2ac9a9d2d968 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 21:15:07 +0100 Subject: on upload store mesh list contents as mesh assets. Build prims by instances not meshs. (some prims can have same mesh) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 31 ++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 4ba8254..ace188c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -617,6 +617,7 @@ namespace OpenSim.Region.ClientStack.Linden OSDArray texture_list = (OSDArray)request["texture_list"]; SceneObjectGroup grp = null; + // create and store texture assets List textures = new List(); for (int i = 0; i < texture_list.Count; i++) { @@ -624,14 +625,28 @@ namespace OpenSim.Region.ClientStack.Linden textureAsset.Data = texture_list[i].AsBinary(); m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); + textureAsset = null; } + // create and store meshs assets + List meshAssets = new List(); for (int i = 0; i < mesh_list.Count; i++) { + AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); + meshAsset.Data = mesh_list[i].AsBinary(); + m_assetService.Store(meshAsset); + meshAssets.Add(meshAsset.FullID); + meshAsset = null; + } + + // build prims from instances + for (int i = 0; i < instance_list.Count; i++) + { PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); Primitive.TextureEntry textureEntry = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); + OSDMap inner_instance_list = (OSDMap)instance_list[i]; OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; @@ -676,14 +691,14 @@ namespace OpenSim.Region.ClientStack.Linden pbs.TextureEntry = textureEntry.GetBytes(); - AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); - meshAsset.Data = mesh_list[i].AsBinary(); - m_assetService.Store(meshAsset); - - pbs.SculptEntry = true; - pbs.SculptTexture = meshAsset.FullID; - pbs.SculptType = (byte)SculptType.Mesh; - pbs.SculptData = meshAsset.Data; + int meshindx = inner_instance_list["mesh"].AsInteger(); + if (meshAssets.Count > meshindx) + { + pbs.SculptEntry = true; + pbs.SculptType = (byte)SculptType.Mesh; + pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction + // data will be requested from asset on rez (i hope) + } Vector3 position = inner_instance_list["position"].AsVector3(); Vector3 scale = inner_instance_list["scale"].AsVector3(); -- cgit v1.1 From fd20ef5c91f5db119d17b1974805b6d4fc2abad3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 22:35:36 +0100 Subject: add some locks to GetTextureModule --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 5b125ea..0ac56ec 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -149,13 +149,16 @@ namespace OpenSim.Region.ClientStack.Linden HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; GetEvents = (x, y, s) => { - try + lock (responses) { - return this.responses[x]; - } - finally - { - responses.Remove(x); + try + { + return this.responses[x]; + } + finally + { + responses.Remove(x); + } } }; @@ -218,14 +221,14 @@ namespace OpenSim.Region.ClientStack.Linden response["content_type"] = "text/plain"; response["keepalive"] = false; response["reusecontext"] = false; - - responses[requestID] = response; + lock (responses) + responses[requestID] = response; return; } response = m_getTextureHandler.Handle(request); - - responses[requestID] = response; + lock (responses) + responses[requestID] = response; } } -- cgit v1.1 From e8ba26eac8fdc438ffb72391d00c852ec1fc9950 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 18 Sep 2012 01:07:44 +0100 Subject: ***TEST*** still bad... create inventory itens for model textures and meshs. Issues: meshs get into root folder, viewer and viewer does not update inventory until relog ( the upload funtion needs to return more information) ,etc. Droping a mesh into a prim, makes viewer think we dropped a sculpt map, but it does work, viewer displays the mesh and physics work (as physics is stored at the sculpt information fields). Textures show up in Textures folder, just its to costly to find that default folder as is.. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 83 ++++++++++++++++++++-- 1 file changed, 76 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ace188c..3789ee9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -583,24 +583,24 @@ namespace OpenSim.Region.ClientStack.Linden if (inventoryType == "sound") { - inType = 1; - assType = 1; + inType = (sbyte)InventoryType.Sound; + assType = (sbyte)AssetType.Sound; } else if (inventoryType == "animation") { - inType = 19; - assType = 20; + inType = (sbyte)InventoryType.Animation; + assType = (sbyte)AssetType.Animation; } else if (inventoryType == "wearable") { - inType = 18; + inType = (sbyte)InventoryType.Wearable; switch (assetType) { case "bodypart": - assType = 13; + assType = (sbyte)AssetType.Bodypart; break; case "clothing": - assType = 5; + assType = (sbyte)AssetType.Clothing; break; } } @@ -625,7 +625,42 @@ namespace OpenSim.Region.ClientStack.Linden textureAsset.Data = texture_list[i].AsBinary(); m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); + + // save it to inventory + if (AddNewInventoryItem != null) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Texture#" + i.ToString(); + InventoryItemBase texitem = new InventoryItemBase(); + texitem.Owner = m_HostCapsObj.AgentID; + texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); + texitem.CreatorData = String.Empty; + texitem.ID = UUID.Random(); + texitem.AssetID = textureAsset.FullID; + texitem.Description = "mesh model texture"; + texitem.Name = name; + texitem.AssetType = (int)AssetType.Texture; + texitem.InvType = (int)InventoryType.Texture; + texitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + texitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + texitem.BasePermissions = (uint)PermissionMask.All; + texitem.EveryOnePermissions = 0; + texitem.NextPermissions = (uint)PermissionMask.All; + texitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); + texitem = null; + } + textureAsset = null; + } // create and store meshs assets @@ -636,6 +671,40 @@ namespace OpenSim.Region.ClientStack.Linden meshAsset.Data = mesh_list[i].AsBinary(); m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); + + // save it to inventory + if (AddNewInventoryItem != null) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Mesh#" + i.ToString(); + InventoryItemBase meshitem = new InventoryItemBase(); + meshitem.Owner = m_HostCapsObj.AgentID; + meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); + meshitem.CreatorData = String.Empty; + meshitem.ID = UUID.Random(); + meshitem.AssetID = meshAsset.FullID; + meshitem.Description = "mesh "; + meshitem.Name = name; + meshitem.AssetType = (int)AssetType.Mesh; + meshitem.InvType = (int)InventoryType.Mesh; + meshitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + meshitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + meshitem.BasePermissions = (uint)PermissionMask.All; + meshitem.EveryOnePermissions = 0; + meshitem.NextPermissions = (uint)PermissionMask.All; + meshitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); + meshitem = null; + } + meshAsset = null; } -- cgit v1.1 From ac2380bbfa5f7f2be8a5a9197f099a88988bce22 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 18 Sep 2012 02:12:07 +0200 Subject: Add booleans to control whether we actually crete inventory items --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 3789ee9..cb6f7a1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -116,6 +116,8 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_dumpAssetsToFile = false; private string m_regionName; private int m_levelUpload = 0; + private bool m_addNewTextures = false; + private bool m_addNewMeshes = false; public BunchOfCaps(Scene scene, Caps caps) { @@ -627,7 +629,7 @@ namespace OpenSim.Region.ClientStack.Linden textures.Add(textureAsset.FullID); // save it to inventory - if (AddNewInventoryItem != null) + if (m_addNewTextures && AddNewInventoryItem != null) { string name = assetName; if (name.Length > 25) @@ -673,7 +675,7 @@ namespace OpenSim.Region.ClientStack.Linden meshAssets.Add(meshAsset.FullID); // save it to inventory - if (AddNewInventoryItem != null) + if (m_addNewMeshes && AddNewInventoryItem != null) { string name = assetName; if (name.Length > 25) -- cgit v1.1 From 51ca84afdfc8a4c3c884b5ab9bd4dffe662087a6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Sep 2012 00:29:16 +0100 Subject: coment out mesh model upload code to add textures and individual meshs assets to inventory, since it may actually be a bad ideia since good model textures are deply related to it and there is no current use for independent mesh assets. Added the option to have a reduced free for textures (2.5 C$ as is, total textures cost rounded to nearest int) compensating for the fact that they can't be used outside the model or its parts. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 380 +++++++++++---------- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 79 +++-- 2 files changed, 255 insertions(+), 204 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index cb6f7a1..073f175 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -116,8 +116,8 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_dumpAssetsToFile = false; private string m_regionName; private int m_levelUpload = 0; - private bool m_addNewTextures = false; - private bool m_addNewMeshes = false; +// private bool m_addNewTextures = false; +// private bool m_addNewMeshes = false; public BunchOfCaps(Scene scene, Caps caps) { @@ -608,172 +608,181 @@ namespace OpenSim.Region.ClientStack.Linden } else if (inventoryType == "object") { - inType = (sbyte)InventoryType.Object; - assType = (sbyte)AssetType.Object; - - List positions = new List(); - List rotations = new List(); - OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); - OSDArray instance_list = (OSDArray)request["instance_list"]; - OSDArray mesh_list = (OSDArray)request["mesh_list"]; - OSDArray texture_list = (OSDArray)request["texture_list"]; - SceneObjectGroup grp = null; - - // create and store texture assets - List textures = new List(); - for (int i = 0; i < texture_list.Count; i++) + if (assetType == "mesh") // this code for now is for mesh models uploads only { - AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, ""); - textureAsset.Data = texture_list[i].AsBinary(); - m_assetService.Store(textureAsset); - textures.Add(textureAsset.FullID); - - // save it to inventory - if (m_addNewTextures && AddNewInventoryItem != null) + inType = (sbyte)InventoryType.Object; + assType = (sbyte)AssetType.Object; + + List positions = new List(); + List rotations = new List(); + OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); + OSDArray instance_list = (OSDArray)request["instance_list"]; + OSDArray mesh_list = (OSDArray)request["mesh_list"]; + OSDArray texture_list = (OSDArray)request["texture_list"]; + SceneObjectGroup grp = null; + + // create and store texture assets + List textures = new List(); + for (int i = 0; i < texture_list.Count; i++) { - string name = assetName; - if (name.Length > 25) - name = name.Substring(0, 24); - name += "_Texture#" + i.ToString(); - InventoryItemBase texitem = new InventoryItemBase(); - texitem.Owner = m_HostCapsObj.AgentID; - texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); - texitem.CreatorData = String.Empty; - texitem.ID = UUID.Random(); - texitem.AssetID = textureAsset.FullID; - texitem.Description = "mesh model texture"; - texitem.Name = name; - texitem.AssetType = (int)AssetType.Texture; - texitem.InvType = (int)InventoryType.Texture; - texitem.Folder = UUID.Zero; // send to default - - // If we set PermissionMask.All then when we rez the item the next permissions will replace the current - // (owner) permissions. This becomes a problem if next permissions are changed. - texitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - - texitem.BasePermissions = (uint)PermissionMask.All; - texitem.EveryOnePermissions = 0; - texitem.NextPermissions = (uint)PermissionMask.All; - texitem.CreationDate = Util.UnixTimeSinceEpoch(); - - AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); - texitem = null; + AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, ""); + textureAsset.Data = texture_list[i].AsBinary(); + m_assetService.Store(textureAsset); + textures.Add(textureAsset.FullID); + /* + don't do this + replace it by optionaly making model textures cost less than if individually uploaded + since they can't be used for other purpuses + + // save it to inventory + if (m_addNewTextures && AddNewInventoryItem != null) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Texture#" + i.ToString(); + InventoryItemBase texitem = new InventoryItemBase(); + texitem.Owner = m_HostCapsObj.AgentID; + texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); + texitem.CreatorData = String.Empty; + texitem.ID = UUID.Random(); + texitem.AssetID = textureAsset.FullID; + texitem.Description = "mesh model texture"; + texitem.Name = name; + texitem.AssetType = (int)AssetType.Texture; + texitem.InvType = (int)InventoryType.Texture; + texitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + texitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + texitem.BasePermissions = (uint)PermissionMask.All; + texitem.EveryOnePermissions = 0; + texitem.NextPermissions = (uint)PermissionMask.All; + texitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); + texitem = null; + } + */ + textureAsset = null; } - textureAsset = null; - - } - - // create and store meshs assets - List meshAssets = new List(); - for (int i = 0; i < mesh_list.Count; i++) - { - AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); - meshAsset.Data = mesh_list[i].AsBinary(); - m_assetService.Store(meshAsset); - meshAssets.Add(meshAsset.FullID); - - // save it to inventory - if (m_addNewMeshes && AddNewInventoryItem != null) + // create and store meshs assets + List meshAssets = new List(); + for (int i = 0; i < mesh_list.Count; i++) { - string name = assetName; - if (name.Length > 25) - name = name.Substring(0, 24); - name += "_Mesh#" + i.ToString(); - InventoryItemBase meshitem = new InventoryItemBase(); - meshitem.Owner = m_HostCapsObj.AgentID; - meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); - meshitem.CreatorData = String.Empty; - meshitem.ID = UUID.Random(); - meshitem.AssetID = meshAsset.FullID; - meshitem.Description = "mesh "; - meshitem.Name = name; - meshitem.AssetType = (int)AssetType.Mesh; - meshitem.InvType = (int)InventoryType.Mesh; - meshitem.Folder = UUID.Zero; // send to default - - // If we set PermissionMask.All then when we rez the item the next permissions will replace the current - // (owner) permissions. This becomes a problem if next permissions are changed. - meshitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - - meshitem.BasePermissions = (uint)PermissionMask.All; - meshitem.EveryOnePermissions = 0; - meshitem.NextPermissions = (uint)PermissionMask.All; - meshitem.CreationDate = Util.UnixTimeSinceEpoch(); - - AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); - meshitem = null; + AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); + meshAsset.Data = mesh_list[i].AsBinary(); + m_assetService.Store(meshAsset); + meshAssets.Add(meshAsset.FullID); + + /* this was a test, funny and showed viewers deal with mesh inventory itens + * nut also same reason as for textures + * let integrated in a model cost eventually less than hipotetical independent meshs assets + * that will be in inventory + // save it to inventory + if (m_addNewMeshes && AddNewInventoryItem != null) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Mesh#" + i.ToString(); + InventoryItemBase meshitem = new InventoryItemBase(); + meshitem.Owner = m_HostCapsObj.AgentID; + meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); + meshitem.CreatorData = String.Empty; + meshitem.ID = UUID.Random(); + meshitem.AssetID = meshAsset.FullID; + meshitem.Description = "mesh "; + meshitem.Name = name; + meshitem.AssetType = (int)AssetType.Mesh; + meshitem.InvType = (int)InventoryType.Mesh; + meshitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + meshitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + meshitem.BasePermissions = (uint)PermissionMask.All; + meshitem.EveryOnePermissions = 0; + meshitem.NextPermissions = (uint)PermissionMask.All; + meshitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); + meshitem = null; + } + */ + meshAsset = null; } - meshAsset = null; - } - - // build prims from instances - for (int i = 0; i < instance_list.Count; i++) - { - PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); + // build prims from instances + for (int i = 0; i < instance_list.Count; i++) + { + PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); - Primitive.TextureEntry textureEntry - = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); + Primitive.TextureEntry textureEntry + = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); - OSDMap inner_instance_list = (OSDMap)instance_list[i]; + OSDMap inner_instance_list = (OSDMap)instance_list[i]; - OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; - for (uint face = 0; face < face_list.Count; face++) - { - OSDMap faceMap = (OSDMap)face_list[(int)face]; - Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face); - if(faceMap.ContainsKey("fullbright")) - f.Fullbright = faceMap["fullbright"].AsBoolean(); - if (faceMap.ContainsKey ("diffuse_color")) - f.RGBA = faceMap["diffuse_color"].AsColor4(); + OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; + for (uint face = 0; face < face_list.Count; face++) + { + OSDMap faceMap = (OSDMap)face_list[(int)face]; + Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face); + if (faceMap.ContainsKey("fullbright")) + f.Fullbright = faceMap["fullbright"].AsBoolean(); + if (faceMap.ContainsKey("diffuse_color")) + f.RGBA = faceMap["diffuse_color"].AsColor4(); - int textureNum = faceMap["image"].AsInteger(); - float imagerot = faceMap["imagerot"].AsInteger(); - float offsets = (float)faceMap["offsets"].AsReal(); - float offsett = (float)faceMap["offsett"].AsReal(); - float scales = (float)faceMap["scales"].AsReal(); - float scalet = (float)faceMap["scalet"].AsReal(); + int textureNum = faceMap["image"].AsInteger(); + float imagerot = faceMap["imagerot"].AsInteger(); + float offsets = (float)faceMap["offsets"].AsReal(); + float offsett = (float)faceMap["offsett"].AsReal(); + float scales = (float)faceMap["scales"].AsReal(); + float scalet = (float)faceMap["scalet"].AsReal(); - if(imagerot != 0) - f.Rotation = imagerot; + if (imagerot != 0) + f.Rotation = imagerot; - if(offsets != 0) - f.OffsetU = offsets; + if (offsets != 0) + f.OffsetU = offsets; - if (offsett != 0) - f.OffsetV = offsett; + if (offsett != 0) + f.OffsetV = offsett; - if (scales != 0) - f.RepeatU = scales; + if (scales != 0) + f.RepeatU = scales; - if (scalet != 0) - f.RepeatV = scalet; + if (scalet != 0) + f.RepeatV = scalet; - if (textures.Count > textureNum) - f.TextureID = textures[textureNum]; - else - f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE; + if (textures.Count > textureNum) + f.TextureID = textures[textureNum]; + else + f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE; - textureEntry.FaceTextures[face] = f; - } + textureEntry.FaceTextures[face] = f; + } - pbs.TextureEntry = textureEntry.GetBytes(); + pbs.TextureEntry = textureEntry.GetBytes(); - int meshindx = inner_instance_list["mesh"].AsInteger(); - if (meshAssets.Count > meshindx) - { - pbs.SculptEntry = true; - pbs.SculptType = (byte)SculptType.Mesh; - pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction - // data will be requested from asset on rez (i hope) - } + int meshindx = inner_instance_list["mesh"].AsInteger(); + if (meshAssets.Count > meshindx) + { + pbs.SculptEntry = true; + pbs.SculptType = (byte)SculptType.Mesh; + pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction + // data will be requested from asset on rez (i hope) + } - Vector3 position = inner_instance_list["position"].AsVector3(); - Vector3 scale = inner_instance_list["scale"].AsVector3(); - Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); + Vector3 position = inner_instance_list["position"].AsVector3(); + Vector3 scale = inner_instance_list["scale"].AsVector3(); + Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); // no longer used - begin ------------------------ // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); @@ -793,23 +802,23 @@ namespace OpenSim.Region.ClientStack.Linden // int owner_mask = permissions["owner_mask"].AsInteger(); // no longer used - end ------------------------ - UUID owner_id = m_HostCapsObj.AgentID; + UUID owner_id = m_HostCapsObj.AgentID; - SceneObjectPart prim - = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); + SceneObjectPart prim + = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); - prim.Scale = scale; - prim.OffsetPosition = position; - rotations.Add(rotation); - positions.Add(position); - prim.UUID = UUID.Random(); - prim.CreatorID = owner_id; - prim.OwnerID = owner_id; - prim.GroupID = UUID.Zero; - prim.LastOwnerID = prim.OwnerID; - prim.CreationDate = Util.UnixTimeSinceEpoch(); - prim.Name = assetName; - prim.Description = ""; + prim.Scale = scale; + prim.OffsetPosition = position; + rotations.Add(rotation); + positions.Add(position); + prim.UUID = UUID.Random(); + prim.CreatorID = owner_id; + prim.OwnerID = owner_id; + prim.GroupID = UUID.Zero; + prim.LastOwnerID = prim.OwnerID; + prim.CreationDate = Util.UnixTimeSinceEpoch(); + prim.Name = assetName; + prim.Description = ""; // prim.BaseMask = (uint)base_mask; // prim.EveryoneMask = (uint)everyone_mask; @@ -817,32 +826,39 @@ namespace OpenSim.Region.ClientStack.Linden // prim.NextOwnerMask = (uint)next_owner_mask; // prim.OwnerMask = (uint)owner_mask; - if (grp == null) - grp = new SceneObjectGroup(prim); - else - grp.AddPart(prim); - } + if (grp == null) + grp = new SceneObjectGroup(prim); + else + grp.AddPart(prim); + } - // Fix first link number - if (grp.Parts.Length > 1) - grp.RootPart.LinkNum++; + // Fix first link number + if (grp.Parts.Length > 1) + grp.RootPart.LinkNum++; - Vector3 rootPos = positions[0]; - grp.AbsolutePosition = rootPos; - for (int i = 0; i < positions.Count; i++) - { - Vector3 offset = positions[i] - rootPos; - grp.Parts[i].OffsetPosition = offset; + Vector3 rootPos = positions[0]; + grp.AbsolutePosition = rootPos; + for (int i = 0; i < positions.Count; i++) + { + Vector3 offset = positions[i] - rootPos; + grp.Parts[i].OffsetPosition = offset; + } + + for (int i = 0; i < rotations.Count; i++) + { + if (i != 0) + grp.Parts[i].RotationOffset = rotations[i]; + } + + grp.UpdateGroupRotationR(rotations[0]); + data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); } - for (int i = 0; i < rotations.Count; i++) + else // not a mesh model { - if (i != 0) - grp.Parts[i].RotationOffset = rotations[i]; + m_log.ErrorFormat("[CAPS Asset Upload] got unsuported assetType for object upload"); + return; } - - grp.UpdateGroupRotationR(rotations[0]); - data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); } AssetBase asset; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index ba73a25..5096a91 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -25,40 +25,67 @@ namespace OpenSim.Region.ClientStack.Linden { public class ModelCost { - float ModelMinCost = 5.0f; // try to favor small meshs versus sculpts - - const float primCreationCost = 0.01f; // 256 prims cost extra 2.56 - - // weigthed size to money convertion - const float bytecost = 1e-4f; - - // for mesh upload fees based on compressed data sizes - // not using streaming physics and server costs as SL apparently does ?? - + // upload fee tunning paramenters + // fees are normalized to 1.0 + // this parameters scale them to basic cost ( so 1.0 translates to 10 ) + + public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) + public float ModelTextureCostFactor = 0.25f; //(2.5c$) scale textures fee to basic. + // promote integration in a model + // since they will not show up in inventory + public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures + + // itens costs in normalized values + // ie will be multiplied by basicCost and factors above + const float primCreationCost = 0.002f; // extra cost for each prim creation overhead + // weigthed size to normalized cost + const float bytecost = 1e-5f; + + // mesh upload fees based on compressed data sizes + // several data sections are counted more that once + // to promote user optimization + // following parameters control how many extra times they are added + // to global size. + // LOD meshs const float medSizeWth = 1f; // 2x const float lowSizeWth = 1.5f; // 2.5x const float lowestSizeWth = 2f; // 3x - // favor potencial optimized meshs versus automatic decomposition + // favor potencially physical optimized meshs versus automatic decomposition const float physMeshSizeWth = 6f; // counts 7x - const float physHullSizeWth = 8f; // counts 9x - + const float physHullSizeWth = 8f; // counts 9x + // stream cost area factors + // more or less like SL const float highLodFactor = 17.36f; const float midLodFactor = 277.78f; const float lowLodFactor = 1111.11f; + // physics cost is below, identical to SL, assuming shape type convex + // server cost is below identical to SL assuming non scripted non physical object + + // internal const int bytesPerCoord = 6; // 3 coords, 2 bytes per each + // storage for a single mesh asset cost parameters private class ameshCostParam { + // LOD sizes for size dependent streaming cost public int highLODSize; public int medLODSize; public int lowLODSize; public int lowestLODSize; + // normalized fee based on compressed data sizes public float costFee; + // physics cost public float physicsCost; } + // calculates a mesh model costs + // returns false on error, with a reason on parameter error + // resources input LLSD request + // basicCost input region assets upload cost + // totalcost returns model total upload fee + // meshcostdata returns detailed costs for viewer public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, LLSDAssetUploadResponseData meshcostdata, out string error) { totalcost = 0; @@ -87,11 +114,12 @@ namespace OpenSim.Region.ClientStack.Linden // textures cost if (resources.texture_list != null && resources.texture_list.Array.Count > 0) { - int textures_cost = resources.texture_list.Array.Count; - textures_cost *= basicCost; + float textures_cost = (float)(resources.texture_list.Array.Count * basicCost); + textures_cost *= ModelTextureCostFactor; - meshcostdata.upload_price_breakdown.texture = textures_cost; - totalcost += textures_cost; + itmp = (int)(textures_cost + 0.5f); // round + meshcostdata.upload_price_breakdown.texture = itmp; + totalcost += itmp; } // meshs assets cost @@ -176,12 +204,16 @@ namespace OpenSim.Region.ClientStack.Linden if (meshcostdata.resource_cost < meshcostdata.simulation_cost) meshcostdata.resource_cost = meshcostdata.simulation_cost; + // scale cost + // at this point a cost of 1.0 whould mean basic cost + meshsfee *= ModelMeshCostFactor; + + if (meshsfee < ModelMinCostFactor) + meshsfee = ModelMinCostFactor; - if (meshsfee < ModelMinCost) - meshsfee = ModelMinCost; + // actually scale it to basic cost + meshsfee *= (float)basicCost; - // scale cost with basic cost changes relative to 10 - meshsfee *= (float)basicCost / 10.0f; meshsfee += 0.5f; // rounding totalcost += (int)meshsfee; @@ -192,6 +224,7 @@ namespace OpenSim.Region.ClientStack.Linden return true; } + // single mesh asset cost private bool MeshCost(byte[] data, ameshCostParam cost, out string error) { cost.highLODSize = 0; @@ -377,6 +410,7 @@ namespace OpenSim.Region.ClientStack.Linden return true; } + // parses a LOD or physics mesh component private bool submesh(byte[] data, int offset, int size, out int ntriangles) { ntriangles = 0; @@ -443,6 +477,7 @@ namespace OpenSim.Region.ClientStack.Linden return true; } + // parses convex hulls component private bool hulls(byte[] data, int offset, int size, out int nvertices, out int nhulls) { nvertices = 0; @@ -512,6 +547,7 @@ namespace OpenSim.Region.ClientStack.Linden return true; } + // returns streaming cost from on mesh LODs sizes in curCost and square of prim size length private float streamingCost(ameshCostParam curCost, float sqdiam) { // compute efective areas @@ -571,7 +607,6 @@ namespace OpenSim.Region.ClientStack.Linden h = 16; // compute cost weighted by relative effective areas - float cost = (float)lst * mlst + (float)l * ml + (float)m * mm + (float)h * mh; cost /= ma; -- cgit v1.1 From fb32604b413052ddedccba36247e676427c48824 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Sep 2012 01:33:16 +0100 Subject: create a single ModelCost provider for the caps instance. Let it know and check scene prim size limits. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 14 ++++-- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 56 +++++++++++++++++----- 2 files changed, 56 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 073f175..0fb6c99 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -87,6 +87,7 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_Scene; private Caps m_HostCapsObj; + private ModelCost m_ModelCost; private static readonly string m_requestPath = "0000/"; // private static readonly string m_mapLayerPath = "0001/"; @@ -123,6 +124,15 @@ namespace OpenSim.Region.ClientStack.Linden { m_Scene = scene; m_HostCapsObj = caps; + + // create a model upload cost provider + m_ModelCost = new ModelCost(); + // tell it about scene object limits + m_ModelCost.NonPhysicalPrimScaleMax = m_Scene.m_maxNonphys; + m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys; +// m_ModelCost.PrimScaleMin = ?? +// m_ModelCost.ObjectLinkedPartsMax = ?? + IConfigSource config = m_Scene.Config; if (config != null) { @@ -193,7 +203,6 @@ namespace OpenSim.Region.ClientStack.Linden { try { - // I don't think this one works... m_HostCapsObj.RegisterHandler( "NewFileAgentInventory", new LLSDStreamhandler( @@ -472,9 +481,8 @@ namespace OpenSim.Region.ClientStack.Linden { string error; int modelcost; - ModelCost mc = new ModelCost(); - if (!mc.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, + if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, meshcostdata, out error)) { client.SendAgentAlertMessage(error, false); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 5096a91..62f1d06 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -23,8 +23,14 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap; namespace OpenSim.Region.ClientStack.Linden { + public struct ModelPrimLimits + { + + } + public class ModelCost { + // upload fee tunning paramenters // fees are normalized to 1.0 // this parameters scale them to basic cost ( so 1.0 translates to 10 ) @@ -66,6 +72,12 @@ namespace OpenSim.Region.ClientStack.Linden // internal const int bytesPerCoord = 6; // 3 coords, 2 bytes per each + // control prims dimensions + public float PrimScaleMin = 0.01f; + public float NonPhysicalPrimScaleMax = 256f; + public float PhysicalPrimScaleMax = 10f; + public int ObjectLinkedPartsMax = 512; + // storage for a single mesh asset cost parameters private class ameshCostParam { @@ -98,7 +110,15 @@ namespace OpenSim.Region.ClientStack.Linden error = "Unable to upload mesh model. missing information."; return false; } - + + int numberInstances = resources.instance_list.Array.Count; + + if( numberInstances > ObjectLinkedPartsMax ) + { + error = "upload failed: Model whould have two many linked prims"; + return false; + } + meshcostdata.model_streaming_cost = 0.0; meshcostdata.simulation_cost = 0.0; meshcostdata.physics_cost = 0.0; @@ -148,12 +168,35 @@ namespace OpenSim.Region.ClientStack.Linden } // instances (prims) cost - int numberInstances = resources.instance_list.Array.Count; + + int mesh; for (int i = 0; i < numberInstances; i++) { Hashtable inst = (Hashtable)resources.instance_list.Array[i]; + ArrayList ascale = (ArrayList)inst["scale"]; + Vector3 scale; + double tmp; + tmp = (double)ascale[0]; + scale.X = (float)tmp; + tmp = (double)ascale[1]; + scale.Y = (float)tmp; + tmp = (double)ascale[2]; + scale.Z = (float)tmp; + + if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) + { + error = " upload fail: Model contains parts with a dimension lower than 0.01. Please adjust scaling"; + return false; + } + + if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) + { + error = "upload fail: Model contains parts larger than maximum allowed. Please adjust scaling"; + return false; + } + if (haveMeshs && inst.ContainsKey("mesh")) { mesh = (int)inst["mesh"]; @@ -165,15 +208,6 @@ namespace OpenSim.Region.ClientStack.Linden } // streamming cost - ArrayList ascale = (ArrayList)inst["scale"]; - Vector3 scale; - double tmp; - tmp = (double)ascale[0]; - scale.X = (float)tmp; - tmp = (double)ascale[1]; - scale.Y = (float)tmp; - tmp = (double)ascale[2]; - scale.Z = (float)tmp; float sqdiam = scale.LengthSquared(); -- cgit v1.1 From 5317b1053f2b8fd81f71c0b95c79aaa03efb47e4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Sep 2012 03:53:51 +0100 Subject: be more tolerant to small prims, skipping them, only failing if they are more than half of total. Add a state control to NewFileAgentInventory to avoid more than one at a time per client. ( Incomplete and possible not that good) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 81 ++++++++++++++++++---- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 17 +++-- 2 files changed, 82 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 0fb6c99..d66076d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -117,6 +117,17 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_dumpAssetsToFile = false; private string m_regionName; private int m_levelUpload = 0; + private float m_PrimScaleMin = 0.001f; + + private enum FileAgentInventoryState : int + { + idle = 0, + processRequest = 1, + waitUpload = 2, + processUpload = 3 + } + private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; + // private bool m_addNewTextures = false; // private bool m_addNewMeshes = false; @@ -132,6 +143,7 @@ namespace OpenSim.Region.ClientStack.Linden m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys; // m_ModelCost.PrimScaleMin = ?? // m_ModelCost.ObjectLinkedPartsMax = ?? +// m_PrimScaleMin = ?? IConfigSource config = m_Scene.Config; if (config != null) @@ -158,6 +170,8 @@ namespace OpenSim.Region.ClientStack.Linden ItemUpdatedCall = m_Scene.CapsUpdateInventoryItemAsset; TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset; GetClient = m_Scene.SceneGraph.GetControllingClient; + + m_FileAgentInventoryState = FileAgentInventoryState.idle; } /// @@ -224,9 +238,7 @@ namespace OpenSim.Region.ClientStack.Linden IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); - m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); - - + m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); m_HostCapsObj.RegisterHandler( "CopyInventoryFromNotecard", @@ -439,6 +451,35 @@ namespace OpenSim.Region.ClientStack.Linden //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); + // start by getting the client + IClientAPI client = null; + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + + // check current state so we only have one service at a time + lock (m_ModelCost) + { + switch (m_FileAgentInventoryState) + { + case FileAgentInventoryState.processRequest: + case FileAgentInventoryState.processUpload: + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Processing previus request", false); + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + break; + case FileAgentInventoryState.waitUpload: + // todo stop current uploader server + break; + case FileAgentInventoryState.idle: + default: + break; + } + + m_FileAgentInventoryState = FileAgentInventoryState.processRequest; + } + uint cost = 0; LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); @@ -447,15 +488,12 @@ namespace OpenSim.Region.ClientStack.Linden llsdRequest.asset_type == "mesh" || llsdRequest.asset_type == "sound") { - ScenePresence avatar = null; - IClientAPI client = null; + ScenePresence avatar = null; m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); // check user level if (avatar != null) { - client = avatar.ControllingClient; - if (avatar.UserLevel < m_levelUpload) { if (client != null) @@ -464,6 +502,8 @@ namespace OpenSim.Region.ClientStack.Linden LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } } @@ -490,6 +530,8 @@ namespace OpenSim.Region.ClientStack.Linden LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } cost = (uint)modelcost; @@ -509,6 +551,8 @@ namespace OpenSim.Region.ClientStack.Linden LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } } @@ -555,8 +599,11 @@ namespace OpenSim.Region.ClientStack.Linden } uploader.OnUpLoad += UploadCompleteHandler; - return uploadResponse; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.waitUpload; + + return uploadResponse; } /// @@ -569,6 +616,9 @@ namespace OpenSim.Region.ClientStack.Linden UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, uint cost) { + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.processUpload; + m_log.DebugFormat( "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", assetID, inventoryItem, inventoryType, assetType); @@ -730,12 +780,19 @@ namespace OpenSim.Region.ClientStack.Linden // build prims from instances for (int i = 0; i < instance_list.Count; i++) { + OSDMap inner_instance_list = (OSDMap)instance_list[i]; + + // skip prims that are 2 small + Vector3 scale = inner_instance_list["scale"].AsVector3(); + + if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) + continue; + PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); Primitive.TextureEntry textureEntry = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); - OSDMap inner_instance_list = (OSDMap)instance_list[i]; OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; for (uint face = 0; face < face_list.Count; face++) @@ -789,7 +846,6 @@ namespace OpenSim.Region.ClientStack.Linden } Vector3 position = inner_instance_list["position"].AsVector3(); - Vector3 scale = inner_instance_list["scale"].AsVector3(); Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); // no longer used - begin ------------------------ @@ -903,6 +959,8 @@ namespace OpenSim.Region.ClientStack.Linden { AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); } + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; } /// @@ -1270,8 +1328,8 @@ namespace OpenSim.Region.ClientStack.Linden res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - httpListener.RemoveStreamHandler("POST", uploaderPath); m_timeoutTimer.Stop(); + httpListener.RemoveStreamHandler("POST", uploaderPath); // TODO: probably make this a better set of extensions here string extension = ".jp2"; @@ -1289,7 +1347,6 @@ namespace OpenSim.Region.ClientStack.Linden { handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); } - return res; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 62f1d06..ece40ac 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.ClientStack.Linden const int bytesPerCoord = 6; // 3 coords, 2 bytes per each // control prims dimensions - public float PrimScaleMin = 0.01f; + public float PrimScaleMin = 0.001f; public float NonPhysicalPrimScaleMax = 256f; public float PhysicalPrimScaleMax = 10f; public int ObjectLinkedPartsMax = 512; @@ -171,6 +171,7 @@ namespace OpenSim.Region.ClientStack.Linden int mesh; + int skipedSmall = 0; for (int i = 0; i < numberInstances; i++) { Hashtable inst = (Hashtable)resources.instance_list.Array[i]; @@ -187,8 +188,10 @@ namespace OpenSim.Region.ClientStack.Linden if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) { - error = " upload fail: Model contains parts with a dimension lower than 0.01. Please adjust scaling"; - return false; +// error = " upload fail: Model contains parts with a dimension lower than 0.001. Please adjust scaling"; +// return false; + skipedSmall++; + continue; } if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) @@ -229,7 +232,13 @@ namespace OpenSim.Region.ClientStack.Linden // charge for prims creation meshsfee += primCreationCost; } - + + if (skipedSmall >0 && skipedSmall > numberInstances / 2) + { + error = "Upload failed: Model contains too much prims smaller than minimum size to ignore"; + return false; + } + if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) meshcostdata.resource_cost = meshcostdata.model_streaming_cost; else -- cgit v1.1 From 629138d4fa16821d9572b58abe234b973ccf945e Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Sep 2012 13:01:34 +0200 Subject: Change texture price back to 10 C$ --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index ece40ac..44a2914 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -36,9 +36,8 @@ namespace OpenSim.Region.ClientStack.Linden // this parameters scale them to basic cost ( so 1.0 translates to 10 ) public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) - public float ModelTextureCostFactor = 0.25f; //(2.5c$) scale textures fee to basic. - // promote integration in a model - // since they will not show up in inventory + public float ModelTextureCostFactor = 1.00f; // keep full price because texture price + // is based on it's storage needs not on usability public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures // itens costs in normalized values -- cgit v1.1 From bf987f96d2339f1471ad5fc5b3df5a7a8b484d6e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 20 Sep 2012 14:32:30 +0100 Subject: Fix model upload rotations and offsets ( i hope ) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 159 ++++++++------------- 1 file changed, 56 insertions(+), 103 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index d66076d..a139ea8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -128,9 +128,6 @@ namespace OpenSim.Region.ClientStack.Linden } private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; -// private bool m_addNewTextures = false; -// private bool m_addNewMeshes = false; - public BunchOfCaps(Scene scene, Caps caps) { m_Scene = scene; @@ -641,6 +638,7 @@ namespace OpenSim.Region.ClientStack.Linden } } + // strings to types if (inventoryType == "sound") { inType = (sbyte)InventoryType.Sound; @@ -687,45 +685,6 @@ namespace OpenSim.Region.ClientStack.Linden textureAsset.Data = texture_list[i].AsBinary(); m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); - /* - don't do this - replace it by optionaly making model textures cost less than if individually uploaded - since they can't be used for other purpuses - - // save it to inventory - if (m_addNewTextures && AddNewInventoryItem != null) - { - string name = assetName; - if (name.Length > 25) - name = name.Substring(0, 24); - name += "_Texture#" + i.ToString(); - InventoryItemBase texitem = new InventoryItemBase(); - texitem.Owner = m_HostCapsObj.AgentID; - texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); - texitem.CreatorData = String.Empty; - texitem.ID = UUID.Random(); - texitem.AssetID = textureAsset.FullID; - texitem.Description = "mesh model texture"; - texitem.Name = name; - texitem.AssetType = (int)AssetType.Texture; - texitem.InvType = (int)InventoryType.Texture; - texitem.Folder = UUID.Zero; // send to default - - // If we set PermissionMask.All then when we rez the item the next permissions will replace the current - // (owner) permissions. This becomes a problem if next permissions are changed. - texitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - - texitem.BasePermissions = (uint)PermissionMask.All; - texitem.EveryOnePermissions = 0; - texitem.NextPermissions = (uint)PermissionMask.All; - texitem.CreationDate = Util.UnixTimeSinceEpoch(); - - AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); - texitem = null; - } - */ - textureAsset = null; } // create and store meshs assets @@ -736,47 +695,9 @@ namespace OpenSim.Region.ClientStack.Linden meshAsset.Data = mesh_list[i].AsBinary(); m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); - - /* this was a test, funny and showed viewers deal with mesh inventory itens - * nut also same reason as for textures - * let integrated in a model cost eventually less than hipotetical independent meshs assets - * that will be in inventory - // save it to inventory - if (m_addNewMeshes && AddNewInventoryItem != null) - { - string name = assetName; - if (name.Length > 25) - name = name.Substring(0, 24); - name += "_Mesh#" + i.ToString(); - InventoryItemBase meshitem = new InventoryItemBase(); - meshitem.Owner = m_HostCapsObj.AgentID; - meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); - meshitem.CreatorData = String.Empty; - meshitem.ID = UUID.Random(); - meshitem.AssetID = meshAsset.FullID; - meshitem.Description = "mesh "; - meshitem.Name = name; - meshitem.AssetType = (int)AssetType.Mesh; - meshitem.InvType = (int)InventoryType.Mesh; - meshitem.Folder = UUID.Zero; // send to default - - // If we set PermissionMask.All then when we rez the item the next permissions will replace the current - // (owner) permissions. This becomes a problem if next permissions are changed. - meshitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - - meshitem.BasePermissions = (uint)PermissionMask.All; - meshitem.EveryOnePermissions = 0; - meshitem.NextPermissions = (uint)PermissionMask.All; - meshitem.CreationDate = Util.UnixTimeSinceEpoch(); - - AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); - meshitem = null; - } - */ - meshAsset = null; } + int skipedMeshs = 0; // build prims from instances for (int i = 0; i < instance_list.Count; i++) { @@ -784,9 +705,12 @@ namespace OpenSim.Region.ClientStack.Linden // skip prims that are 2 small Vector3 scale = inner_instance_list["scale"].AsVector3(); - + if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) + { + skipedMeshs++; continue; + } PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); @@ -836,21 +760,33 @@ namespace OpenSim.Region.ClientStack.Linden pbs.TextureEntry = textureEntry.GetBytes(); - int meshindx = inner_instance_list["mesh"].AsInteger(); - if (meshAssets.Count > meshindx) + bool hasmesh = false; + if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ... { - pbs.SculptEntry = true; - pbs.SculptType = (byte)SculptType.Mesh; - pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction - // data will be requested from asset on rez (i hope) + int meshindx = inner_instance_list["mesh"].AsInteger(); + if (meshAssets.Count > meshindx) + { + pbs.SculptEntry = true; + pbs.SculptType = (byte)SculptType.Mesh; + pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction + // data will be requested from asset on rez (i hope) + hasmesh = true; + } } Vector3 position = inner_instance_list["position"].AsVector3(); Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); + // for now viwers do send fixed defaults + // but this may change +// int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); + byte physicsShapeType = (byte)PhysShapeType.prim; // default for mesh is simple convex + if(hasmesh) + physicsShapeType = (byte) PhysShapeType.convex; // default for mesh is simple convex +// int material = inner_instance_list["material"].AsInteger(); + byte material = (byte)Material.Wood; + // no longer used - begin ------------------------ -// int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); -// int material = inner_instance_list["material"].AsInteger(); // int mesh = inner_instance_list["mesh"].AsInteger(); // OSDMap permissions = (OSDMap)inner_instance_list["permissions"]; @@ -872,7 +808,7 @@ namespace OpenSim.Region.ClientStack.Linden = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); prim.Scale = scale; - prim.OffsetPosition = position; +// prim.OffsetPosition = position; rotations.Add(rotation); positions.Add(position); prim.UUID = UUID.Random(); @@ -883,6 +819,8 @@ namespace OpenSim.Region.ClientStack.Linden prim.CreationDate = Util.UnixTimeSinceEpoch(); prim.Name = assetName; prim.Description = ""; + prim.Material = material; + prim.PhysicsShapeType = physicsShapeType; // prim.BaseMask = (uint)base_mask; // prim.EveryoneMask = (uint)everyone_mask; @@ -896,25 +834,40 @@ namespace OpenSim.Region.ClientStack.Linden grp.AddPart(prim); } - // Fix first link number + Vector3 rootPos = positions[0]; + if (grp.Parts.Length > 1) + { + // Fix first link number grp.RootPart.LinkNum++; - Vector3 rootPos = positions[0]; - grp.AbsolutePosition = rootPos; - for (int i = 0; i < positions.Count; i++) - { - Vector3 offset = positions[i] - rootPos; - grp.Parts[i].OffsetPosition = offset; - } + Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]); + Quaternion tmprot; + Vector3 offset; + + // fix children rotations and positions + for (int i = 1; i < rotations.Count; i++) + { + tmprot = rotations[i]; + tmprot = rootRotConj * tmprot; + + grp.Parts[i].RotationOffset = tmprot; - for (int i = 0; i < rotations.Count; i++) + offset = positions[i] - rootPos; + + offset *= rootRotConj; + grp.Parts[i].OffsetPosition = offset; + } + + grp.AbsolutePosition = rootPos; + grp.UpdateGroupRotationR(rotations[0]); + } + else { - if (i != 0) - grp.Parts[i].RotationOffset = rotations[i]; + grp.AbsolutePosition = rootPos; + grp.UpdateGroupRotationR(rotations[0]); } - grp.UpdateGroupRotationR(rotations[0]); data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); } -- cgit v1.1 From 9ff6c85325bfe8a046abaf72267e215f05ec893e Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 20 Sep 2012 15:39:46 +0200 Subject: Make uploads free for now - we will have to announce this --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 44a2914..8099069 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -35,10 +35,13 @@ namespace OpenSim.Region.ClientStack.Linden // fees are normalized to 1.0 // this parameters scale them to basic cost ( so 1.0 translates to 10 ) - public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) - public float ModelTextureCostFactor = 1.00f; // keep full price because texture price + public float ModelMeshCostFactor = 0f; //Free + public float ModelMinCostFactor = 0f; // Free + //public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) + //public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures + + //public float ModelTextureCostFactor = 1.00f; // keep full price because texture price // is based on it's storage needs not on usability - public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures // itens costs in normalized values // ie will be multiplied by basicCost and factors above -- cgit v1.1 From 5d63c20122351296298d9ec841a569e1c008ba4b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 20 Sep 2012 15:41:16 +0200 Subject: refix prior commit --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 8099069..da701ba 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.ClientStack.Linden //public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) //public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures - //public float ModelTextureCostFactor = 1.00f; // keep full price because texture price + public float ModelTextureCostFactor = 1.00f; // keep full price because texture price // is based on it's storage needs not on usability // itens costs in normalized values -- cgit v1.1 From f9c24c9414134af04fea3dd6ff39800856aec10e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 21 Sep 2012 11:50:14 +0100 Subject: read model upload cost parameters from config [Economy] section --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 21 +++++++++++++++++++++ .../ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 6 ++---- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index a139ea8..1b47fca 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -118,6 +118,7 @@ namespace OpenSim.Region.ClientStack.Linden private string m_regionName; private int m_levelUpload = 0; private float m_PrimScaleMin = 0.001f; + private bool m_enableFreeTestModelUpload = false; private enum FileAgentInventoryState : int { @@ -142,6 +143,11 @@ namespace OpenSim.Region.ClientStack.Linden // m_ModelCost.ObjectLinkedPartsMax = ?? // m_PrimScaleMin = ?? + float modelTextureUploadFactor = m_ModelCost.ModelTextureCostFactor; + float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; + float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; + + IConfigSource config = m_Scene.Config; if (config != null) { @@ -156,6 +162,20 @@ namespace OpenSim.Region.ClientStack.Linden { m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); } + // economy for model upload + IConfig EconomyConfig = config.Configs["Economy"]; + if (EconomyConfig != null) + { + modelUploadFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", modelUploadFactor); + modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); + modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); + m_enableFreeTestModelUpload = EconomyConfig.GetBoolean("MeshModelUploadAllowFreeTest", false); + + m_ModelCost.ModelMeshCostFactor = modelUploadFactor; + m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; + m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; + } + } m_assetService = m_Scene.AssetService; @@ -912,6 +932,7 @@ namespace OpenSim.Region.ClientStack.Linden { AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); } + lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index ece40ac..830c46d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -31,14 +31,12 @@ namespace OpenSim.Region.ClientStack.Linden public class ModelCost { - // upload fee tunning paramenters + // upload fee defaults // fees are normalized to 1.0 // this parameters scale them to basic cost ( so 1.0 translates to 10 ) public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) - public float ModelTextureCostFactor = 0.25f; //(2.5c$) scale textures fee to basic. - // promote integration in a model - // since they will not show up in inventory + public float ModelTextureCostFactor = 1.0f; // scale textures fee to basic. public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures // itens costs in normalized values -- cgit v1.1 From 7de67d5680b2eb028bb17fae0d80d1f78ccd3a19 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 22 Sep 2012 12:00:14 +0100 Subject: removed unused data in MeshUploadFlag response --- .../ClientStack/Linden/Caps/MeshUploadFlagModule.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs index 44a6883..0251ac4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs @@ -129,15 +129,15 @@ namespace OpenSim.Region.ClientStack.Linden // m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request"); OSDMap data = new OSDMap(); - ScenePresence sp = m_scene.GetScenePresence(m_agentID); - data["username"] = sp.Firstname + "." + sp.Lastname; - data["display_name_next_update"] = new OSDDate(DateTime.Now); - data["legacy_first_name"] = sp.Firstname; +// ScenePresence sp = m_scene.GetScenePresence(m_agentID); +// data["username"] = sp.Firstname + "." + sp.Lastname; +// data["display_name_next_update"] = new OSDDate(DateTime.Now); +// data["legacy_first_name"] = sp.Firstname; data["mesh_upload_status"] = "valid"; - data["display_name"] = sp.Firstname + " " + sp.Lastname; - data["legacy_last_name"] = sp.Lastname; - data["id"] = m_agentID; - data["is_display_name_default"] = true; +// data["display_name"] = sp.Firstname + " " + sp.Lastname; +// data["legacy_last_name"] = sp.Lastname; +// data["id"] = m_agentID; +// data["is_display_name_default"] = true; //Send back data Hashtable responsedata = new Hashtable(); -- cgit v1.1 From 4bba72b7afc104ea5a42acb6206c1c07fbba099b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 22 Sep 2012 16:47:15 +0100 Subject: removed AssetUploaderWithCost, fixing AssetUploader. add parsing of some more needed fields in request --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 66 ++++++++-------------- 1 file changed, 24 insertions(+), 42 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 1b47fca..b64453a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -54,8 +54,8 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap; namespace OpenSim.Region.ClientStack.Linden { public delegate void UpLoadedAsset( - string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, - byte[] data, string inventoryType, string assetType); + string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, + byte[] data, string inventoryType, string assetType, int cost); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -119,6 +119,7 @@ namespace OpenSim.Region.ClientStack.Linden private int m_levelUpload = 0; private float m_PrimScaleMin = 0.001f; private bool m_enableFreeTestModelUpload = false; + private bool m_enableModelUploadTextureToInventory = false; private enum FileAgentInventoryState : int { @@ -147,7 +148,6 @@ namespace OpenSim.Region.ClientStack.Linden float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; - IConfigSource config = m_Scene.Config; if (config != null) { @@ -170,12 +170,12 @@ namespace OpenSim.Region.ClientStack.Linden modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); m_enableFreeTestModelUpload = EconomyConfig.GetBoolean("MeshModelUploadAllowFreeTest", false); + m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", false); m_ModelCost.ModelMeshCostFactor = modelUploadFactor; m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; } - } m_assetService = m_Scene.AssetService; @@ -426,37 +426,13 @@ namespace OpenSim.Region.ClientStack.Linden return UUID.Zero; } - - private delegate void UploadWithCostCompleteDelegate(string assetName, - string assetDescription, UUID assetID, UUID inventoryItem, - UUID parentFolder, byte[] data, string inventoryType, - string assetType, uint cost); - - private class AssetUploaderWithCost : AssetUploader +/* + private class AssetUploaderExtraParameters { - private uint m_cost; + public int total_cost; + public UUID textureFolder = UUID.Zero; +*/ - public event UploadWithCostCompleteDelegate OnUpLoad; - - public AssetUploaderWithCost(string assetName, string description, UUID assetID, - UUID inventoryItem, UUID parentFolderID, string invType, string assetType, - string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : - base(assetName, description, assetID, inventoryItem, parentFolderID, - invType, assetType, path, httpServer, dumpAssetsToFile) - { - m_cost = cost; - - base.OnUpLoad += UploadCompleteHandler; - } - - private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType) - { - OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, - data, inventoryType, assetType, m_cost); - } - } /// /// @@ -497,7 +473,7 @@ namespace OpenSim.Region.ClientStack.Linden m_FileAgentInventoryState = FileAgentInventoryState.processRequest; } - uint cost = 0; + int cost = 0; LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || @@ -551,11 +527,11 @@ namespace OpenSim.Region.ClientStack.Linden m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } - cost = (uint)modelcost; + cost = modelcost; } else { - cost = (uint)baseCost; + cost = baseCost; } // check funds @@ -584,8 +560,8 @@ namespace OpenSim.Region.ClientStack.Linden UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploaderWithCost uploader = - new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + AssetUploader uploader = + new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); m_HostCapsObj.HttpListener.AddStreamHandler( @@ -631,7 +607,7 @@ namespace OpenSim.Region.ClientStack.Linden /// public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType, uint cost) + string assetType, int cost) { lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.processUpload; @@ -920,6 +896,7 @@ namespace OpenSim.Region.ClientStack.Linden // If we set PermissionMask.All then when we rez the item the next permissions will replace the current // (owner) permissions. This becomes a problem if next permissions are changed. + item.CurrentPermissions = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); @@ -930,7 +907,7 @@ namespace OpenSim.Region.ClientStack.Linden if (AddNewInventoryItem != null) { - AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); + AddNewInventoryItem(m_HostCapsObj.AgentID, item,(uint) cost); } lock (m_ModelCost) @@ -1247,6 +1224,7 @@ namespace OpenSim.Region.ClientStack.Linden private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public event UpLoadedAsset OnUpLoad; private UpLoadedAsset handlerUpLoad = null; @@ -1261,11 +1239,14 @@ namespace OpenSim.Region.ClientStack.Linden private string m_invType = String.Empty; private string m_assetType = String.Empty; + private int m_cost; + private Timer m_timeoutTimer = new Timer(); + public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, - IHttpServer httpServer, bool dumpAssetsToFile) + IHttpServer httpServer, bool dumpAssetsToFile, int totalCost) { m_assetName = assetName; m_assetDes = description; @@ -1277,6 +1258,7 @@ namespace OpenSim.Region.ClientStack.Linden m_assetType = assetType; m_invType = invType; m_dumpAssetsToFile = dumpAssetsToFile; + m_cost = totalCost; m_timeoutTimer.Elapsed += TimedOut; m_timeoutTimer.Interval = 120000; @@ -1319,7 +1301,7 @@ namespace OpenSim.Region.ClientStack.Linden handlerUpLoad = OnUpLoad; if (handlerUpLoad != null) { - handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); + handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost); } return res; } -- cgit v1.1 From 11e05217df2de7ce7da581a2332ee4871f75a527 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 22 Sep 2012 21:14:15 +0100 Subject: report asset upload errors the right away --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 80 +++++++++++++++++----- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 24 +++---- 2 files changed, 75 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index b64453a..a934113 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.Linden { public delegate void UpLoadedAsset( string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, - byte[] data, string inventoryType, string assetType, int cost); + byte[] data, string inventoryType, string assetType, int cost, ref string error); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -455,11 +455,14 @@ namespace OpenSim.Region.ClientStack.Linden { case FileAgentInventoryState.processRequest: case FileAgentInventoryState.processUpload: - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Processing previus request", false); + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = "Uploader busy processing previus request"; + resperror.identifier = UUID.Zero; + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + errorResponse.error = resperror; return errorResponse; break; case FileAgentInventoryState.waitUpload: @@ -489,12 +492,15 @@ namespace OpenSim.Region.ClientStack.Linden { if (avatar.UserLevel < m_levelUpload) { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = "Insufficient permissions to upload"; + resperror.identifier = UUID.Zero; + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + errorResponse.error = resperror; lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; @@ -518,11 +524,15 @@ namespace OpenSim.Region.ClientStack.Linden if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, meshcostdata, out error)) { - client.SendAgentAlertMessage(error, false); + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = error; + resperror.identifier = UUID.Zero; LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + errorResponse.error = resperror; + lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; @@ -539,11 +549,14 @@ namespace OpenSim.Region.ClientStack.Linden { if (!mm.UploadCovered(client.AgentId, (int)cost)) { - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = "Insuficient funds"; + resperror.identifier = UUID.Zero; LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + errorResponse.error = resperror; lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; @@ -607,8 +620,9 @@ namespace OpenSim.Region.ClientStack.Linden /// public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType, int cost) + string assetType, int cost, ref string error) { + lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.processUpload; @@ -619,17 +633,13 @@ namespace OpenSim.Region.ClientStack.Linden sbyte assType = 0; sbyte inType = 0; - IClientAPI client = null; - IMoneyModule mm = m_Scene.RequestModuleInterface(); if (mm != null) { // make sure client still has enougth credit if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost)) { - m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + error = "Insufficient funds."; return; } } @@ -668,6 +678,25 @@ namespace OpenSim.Region.ClientStack.Linden List positions = new List(); List rotations = new List(); OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); + + // compare and get updated information + + bool mismatchError = true; + + while (mismatchError) + { + mismatchError = false; + } + + if (mismatchError) + { + error = "Upload and fee estimation information don't match"; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; + + return; + } + OSDArray instance_list = (OSDArray)request["instance_list"]; OSDArray mesh_list = (OSDArray)request["mesh_list"]; OSDArray texture_list = (OSDArray)request["texture_list"]; @@ -1240,7 +1269,8 @@ namespace OpenSim.Region.ClientStack.Linden private string m_invType = String.Empty; private string m_assetType = String.Empty; private int m_cost; - + private string m_error = String.Empty; + private Timer m_timeoutTimer = new Timer(); @@ -1278,12 +1308,13 @@ namespace OpenSim.Region.ClientStack.Linden UUID inv = inventoryItemID; string res = String.Empty; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); +/* uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - +*/ m_timeoutTimer.Stop(); httpListener.RemoveStreamHandler("POST", uploaderPath); @@ -1301,8 +1332,25 @@ namespace OpenSim.Region.ClientStack.Linden handlerUpLoad = OnUpLoad; if (handlerUpLoad != null) { - handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost); + handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost, ref m_error); } + if(m_error == String.Empty) + { + uploadComplete.new_asset = newAssetID.ToString(); + uploadComplete.new_inventory_item = inv; + uploadComplete.state = "complete"; + } + else + { + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = m_error; + resperror.identifier = inv; + + uploadComplete.error = resperror; + uploadComplete.state = "failed"; + } + + res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); return res; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 830c46d..7a80c72 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -105,7 +105,7 @@ namespace OpenSim.Region.ClientStack.Linden resources.instance_list == null || resources.instance_list.Array.Count == 0) { - error = "Unable to upload mesh model. missing information."; + error = "missing model information."; return false; } @@ -113,7 +113,7 @@ namespace OpenSim.Region.ClientStack.Linden if( numberInstances > ObjectLinkedPartsMax ) { - error = "upload failed: Model whould have two many linked prims"; + error = "Model whould have more than " + ObjectLinkedPartsMax.ToString() + " linked prims"; return false; } @@ -186,15 +186,13 @@ namespace OpenSim.Region.ClientStack.Linden if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) { -// error = " upload fail: Model contains parts with a dimension lower than 0.001. Please adjust scaling"; -// return false; skipedSmall++; continue; } if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) { - error = "upload fail: Model contains parts larger than maximum allowed. Please adjust scaling"; + error = "Model contains parts with sides larger than " + NonPhysicalPrimScaleMax.ToString() + "m. Please ajust scale"; return false; } @@ -204,7 +202,7 @@ namespace OpenSim.Region.ClientStack.Linden if (mesh >= numberMeshs) { - error = "Unable to upload mesh model. incoerent information."; + error = "Incoerent model information."; return false; } @@ -233,7 +231,7 @@ namespace OpenSim.Region.ClientStack.Linden if (skipedSmall >0 && skipedSmall > numberInstances / 2) { - error = "Upload failed: Model contains too much prims smaller than minimum size to ignore"; + error = "Model contains too many prims smaller than " + PrimScaleMin.ToString() + "m"; return false; } @@ -279,14 +277,14 @@ namespace OpenSim.Region.ClientStack.Linden if (data == null || data.Length == 0) { - error = "Unable to upload mesh model. missing information."; + error = "Missing model information."; return false; } OSD meshOsd = null; int start = 0; - error = "Unable to upload mesh model. Invalid data"; + error = "Invalid model data"; using (MemoryStream ms = new MemoryStream(data)) { @@ -334,13 +332,13 @@ namespace OpenSim.Region.ClientStack.Linden if (submesh_offset < 0 || hulls_size == 0) { - error = "Unable to upload mesh model. missing physics_convex block"; + error = "Missing physics_convex block"; return false; } if (!hulls(data, submesh_offset, hulls_size, out phys_hullsvertices, out phys_nhulls)) { - error = "Unable to upload mesh model. bad physics_convex block"; + error = "Bad physics_convex block"; return false; } @@ -360,7 +358,7 @@ namespace OpenSim.Region.ClientStack.Linden if (submesh_offset < 0 || highlod_size <= 0) { - error = "Unable to upload mesh model. missing high_lod"; + error = "Missing high_lod block"; return false; } @@ -418,7 +416,7 @@ namespace OpenSim.Region.ClientStack.Linden if (!submesh(data, submesh_offset, physmesh_size, out phys_ntriangles)) { - error = "Unable to upload mesh model. parsing error"; + error = "Model data parsing error"; return false; } } -- cgit v1.1 From 64db9e41143c36ee1638f2c453b4645ff4ed008f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 23 Sep 2012 15:04:10 +0100 Subject: try to allow free uploads for testing, if users prefix names with "TEST-". Let textures get into inventory again. Both features under config control. Have direct warnings to client, including a final one on upload complete since i see nothing. problems: textures don't showup in inventory til relog, also issues with permitions. A few more changes --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 225 +++++++++++++++++---- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 26 ++- 2 files changed, 210 insertions(+), 41 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index a934113..21a1005 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -55,7 +55,9 @@ namespace OpenSim.Region.ClientStack.Linden { public delegate void UpLoadedAsset( string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, - byte[] data, string inventoryType, string assetType, int cost, ref string error); + byte[] data, string inventoryType, string assetType, + int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, + bool IsAtestUpload, ref string error); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -118,8 +120,9 @@ namespace OpenSim.Region.ClientStack.Linden private string m_regionName; private int m_levelUpload = 0; private float m_PrimScaleMin = 0.001f; - private bool m_enableFreeTestModelUpload = false; + private bool m_enableFreeTestUpload = false; private bool m_enableModelUploadTextureToInventory = false; + private UUID m_testAssetsCreatorID = UUID.Zero; private enum FileAgentInventoryState : int { @@ -148,6 +151,9 @@ namespace OpenSim.Region.ClientStack.Linden float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; + // can be UUID.zero. This is me at OSG, should be a valid grid ID, is case a bad config + UUID.TryParse("58e06f33-ea8c-4ff6-9af5-420606926118", out m_testAssetsCreatorID); + IConfigSource config = m_Scene.Config; if (config != null) { @@ -169,9 +175,18 @@ namespace OpenSim.Region.ClientStack.Linden modelUploadFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", modelUploadFactor); modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); - m_enableFreeTestModelUpload = EconomyConfig.GetBoolean("MeshModelUploadAllowFreeTest", false); m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", false); + m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", false); + string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", m_testAssetsCreatorID.ToString()); + if (testcreator != "") + { + UUID id; + UUID.TryParse(testcreator, out id); + if (id != null) + m_testAssetsCreatorID = id; + } + m_ModelCost.ModelMeshCostFactor = modelUploadFactor; m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; @@ -426,13 +441,6 @@ namespace OpenSim.Region.ClientStack.Linden return UUID.Zero; } -/* - private class AssetUploaderExtraParameters - { - public int total_cost; - public UUID textureFolder = UUID.Zero; -*/ - /// /// @@ -477,6 +485,11 @@ namespace OpenSim.Region.ClientStack.Linden } int cost = 0; + int nreqtextures = 0; + int nreqmeshs= 0; + int nreqinstances = 0; + bool IsAtestUpload = false; + LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || @@ -496,7 +509,6 @@ namespace OpenSim.Region.ClientStack.Linden resperror.message = "Insufficient permissions to upload"; resperror.identifier = UUID.Zero; - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; @@ -516,13 +528,15 @@ namespace OpenSim.Region.ClientStack.Linden if (mm != null) baseCost = mm.UploadCharge; + string warning = String.Empty; + if (llsdRequest.asset_type == "mesh") { string error; int modelcost; - + if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, - meshcostdata, out error)) + meshcostdata, out error, ref warning)) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = error; @@ -544,8 +558,21 @@ namespace OpenSim.Region.ClientStack.Linden cost = baseCost; } + if (m_enableFreeTestUpload && cost > 0 && mm != null) + { + string str = llsdRequest.name; + if (str.Length > 5 && str.StartsWith("TEST-")) + { + warning += "Upload will have no cost, but for personal test purposes only. Other uses are forbiden"; + IsAtestUpload = true; + } + } + + if (client != null && warning != String.Empty) + client.SendAgentAlertMessage(warning, true); + // check funds - if (mm != null) + if (!IsAtestUpload && mm != null && cost >0) { if (!mm.UploadCovered(client.AgentId, (int)cost)) { @@ -572,10 +599,15 @@ namespace OpenSim.Region.ClientStack.Linden UUID newInvItem = UUID.Random(); UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + UUID texturesFolder = UUID.Zero; + + if(!IsAtestUpload && m_enableModelUploadTextureToInventory) + texturesFolder = llsdRequest.texture_folder_id; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); + llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, + texturesFolder, nreqtextures, nreqmeshs, nreqinstances,IsAtestUpload); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -620,7 +652,9 @@ namespace OpenSim.Region.ClientStack.Linden /// public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType, int cost, ref string error) + string assetType, int cost, + UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, + bool IsAtestUpload, ref string error) { lock (m_ModelCost) @@ -633,6 +667,18 @@ namespace OpenSim.Region.ClientStack.Linden sbyte assType = 0; sbyte inType = 0; + UUID owner_id = m_HostCapsObj.AgentID; + UUID creatorID; + + bool istest = IsAtestUpload && m_enableFreeTestUpload && (cost > 0); + + if (istest) + creatorID = m_testAssetsCreatorID; + else + creatorID = owner_id; + + string creatorIDstr = creatorID.ToString(); + IMoneyModule mm = m_Scene.RequestModuleInterface(); if (mm != null) { @@ -703,20 +749,56 @@ namespace OpenSim.Region.ClientStack.Linden SceneObjectGroup grp = null; // create and store texture assets + bool doTextInv = (!istest && m_enableModelUploadTextureToInventory && + texturesFolder != UUID.Zero); + + List textures = new List(); + for (int i = 0; i < texture_list.Count; i++) { - AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, ""); + AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, creatorIDstr); textureAsset.Data = texture_list[i].AsBinary(); m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); + + if (doTextInv) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Texture#" + i.ToString(); + InventoryItemBase texitem = new InventoryItemBase(); + texitem.Owner = m_HostCapsObj.AgentID; + texitem.CreatorId = creatorIDstr; + texitem.CreatorData = String.Empty; + texitem.ID = UUID.Random(); + texitem.AssetID = textureAsset.FullID; + texitem.Description = "mesh model texture"; + texitem.Name = name; + texitem.AssetType = (int)AssetType.Texture; + texitem.InvType = (int)InventoryType.Texture; + texitem.Folder = texturesFolder; + + texitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + texitem.BasePermissions = (uint)PermissionMask.All; + texitem.EveryOnePermissions = 0; + texitem.NextPermissions = (uint)PermissionMask.All; + texitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); + texitem = null; + // this aren't showing up in viewer until relog :( + } } // create and store meshs assets List meshAssets = new List(); for (int i = 0; i < mesh_list.Count; i++) { - AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); + AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); meshAsset.Data = mesh_list[i].AsBinary(); m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); @@ -827,7 +909,7 @@ namespace OpenSim.Region.ClientStack.Linden // int owner_mask = permissions["owner_mask"].AsInteger(); // no longer used - end ------------------------ - UUID owner_id = m_HostCapsObj.AgentID; + SceneObjectPart prim = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); @@ -837,13 +919,29 @@ namespace OpenSim.Region.ClientStack.Linden rotations.Add(rotation); positions.Add(position); prim.UUID = UUID.Random(); - prim.CreatorID = owner_id; + prim.CreatorID = creatorID; prim.OwnerID = owner_id; prim.GroupID = UUID.Zero; - prim.LastOwnerID = prim.OwnerID; + prim.LastOwnerID = creatorID; prim.CreationDate = Util.UnixTimeSinceEpoch(); - prim.Name = assetName; - prim.Description = ""; + + if (grp == null) + prim.Name = assetName; + else + prim.Name = assetName + "#" + i.ToString(); + + if (istest) + { + prim.BaseMask = (uint)(PermissionMask.Move | PermissionMask.Modify); + prim.EveryoneMask = 0; + prim.GroupMask = 0; + prim.NextOwnerMask = 0; + prim.OwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify); + + prim.Description = "For personal testing only. Other uses are forbiden"; + } + else + prim.Description = ""; prim.Material = material; prim.PhysicsShapeType = physicsShapeType; @@ -854,7 +952,10 @@ namespace OpenSim.Region.ClientStack.Linden // prim.OwnerMask = (uint)owner_mask; if (grp == null) + { grp = new SceneObjectGroup(prim); + grp.LastOwnerID = creatorID; + } else grp.AddPart(prim); } @@ -904,7 +1005,7 @@ namespace OpenSim.Region.ClientStack.Linden } AssetBase asset; - asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString()); + asset = new AssetBase(assetID, assetName, assType, creatorIDstr); asset.Data = data; if (AddNewAsset != null) AddNewAsset(asset); @@ -913,11 +1014,14 @@ namespace OpenSim.Region.ClientStack.Linden InventoryItemBase item = new InventoryItemBase(); item.Owner = m_HostCapsObj.AgentID; - item.CreatorId = m_HostCapsObj.AgentID.ToString(); + item.CreatorId = creatorIDstr; item.CreatorData = String.Empty; item.ID = inventoryItem; item.AssetID = asset.FullID; - item.Description = assetDescription; + if (istest) + item.Description = "For personal testing only. Other uses are forbiden"; + else + item.Description = assetDescription; item.Name = assetName; item.AssetType = assType; item.InvType = inType; @@ -926,17 +1030,53 @@ namespace OpenSim.Region.ClientStack.Linden // If we set PermissionMask.All then when we rez the item the next permissions will replace the current // (owner) permissions. This becomes a problem if next permissions are changed. - item.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + if (istest) + { + item.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Modify); + + item.BasePermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); + item.EveryOnePermissions = 0; + item.NextPermissions = 0; + } + else + { + item.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + item.BasePermissions = (uint)PermissionMask.All; + item.EveryOnePermissions = 0; + item.NextPermissions = (uint)PermissionMask.All; + } - item.BasePermissions = (uint)PermissionMask.All; - item.EveryOnePermissions = 0; - item.NextPermissions = (uint)PermissionMask.All; item.CreationDate = Util.UnixTimeSinceEpoch(); + IClientAPI client = null; + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + if (AddNewInventoryItem != null) { - AddNewInventoryItem(m_HostCapsObj.AgentID, item,(uint) cost); + if (istest) + { + AddNewInventoryItem(m_HostCapsObj.AgentID, item, 0); + if (client != null) + client.SendAgentAlertMessage("Upload complete with no cost for personal testing purposes only. Other uses are forbiden", true); + } + else + { + AddNewInventoryItem(m_HostCapsObj.AgentID, item, (uint)cost); + if (client != null) + { + // let users see anything.. i don't so far + string str; + if (cost > 0) + // dont remember where is money unit name to put here + str = "Upload complete. charged " + cost.ToString() + "$"; + else + str = "Upload complete"; + client.SendAgentAlertMessage(str, true); + } + } } lock (m_ModelCost) @@ -1272,11 +1412,17 @@ namespace OpenSim.Region.ClientStack.Linden private string m_error = String.Empty; private Timer m_timeoutTimer = new Timer(); - + private UUID m_texturesFolder; + private int m_nreqtextures; + private int m_nreqmeshs; + private int m_nreqinstances; + private bool m_IsAtestUpload; public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, - IHttpServer httpServer, bool dumpAssetsToFile, int totalCost) + IHttpServer httpServer, bool dumpAssetsToFile, + int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, + bool IsAtestUpload) { m_assetName = assetName; m_assetDes = description; @@ -1290,6 +1436,12 @@ namespace OpenSim.Region.ClientStack.Linden m_dumpAssetsToFile = dumpAssetsToFile; m_cost = totalCost; + m_texturesFolder = texturesFolder; + m_nreqtextures = nreqtextures; + m_nreqmeshs = nreqmeshs; + m_nreqinstances = nreqinstances; + m_IsAtestUpload = IsAtestUpload; + m_timeoutTimer.Elapsed += TimedOut; m_timeoutTimer.Interval = 120000; m_timeoutTimer.AutoReset = false; @@ -1332,12 +1484,15 @@ namespace OpenSim.Region.ClientStack.Linden handlerUpLoad = OnUpLoad; if (handlerUpLoad != null) { - handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost, ref m_error); + handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, + m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, ref m_error); } if(m_error == String.Empty) { uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = inv; +// if (m_texturesFolder != UUID.Zero) +// uploadComplete.new_texture_folder_id = m_texturesFolder; uploadComplete.state = "complete"; } else diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 7a80c72..f03d8d8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -96,7 +96,8 @@ namespace OpenSim.Region.ClientStack.Linden // basicCost input region assets upload cost // totalcost returns model total upload fee // meshcostdata returns detailed costs for viewer - public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, LLSDAssetUploadResponseData meshcostdata, out string error) + public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, + LLSDAssetUploadResponseData meshcostdata, out string error, ref string warning) { totalcost = 0; error = string.Empty; @@ -229,10 +230,18 @@ namespace OpenSim.Region.ClientStack.Linden meshsfee += primCreationCost; } - if (skipedSmall >0 && skipedSmall > numberInstances / 2) + if (skipedSmall > 0) { - error = "Model contains too many prims smaller than " + PrimScaleMin.ToString() + "m"; - return false; + if (skipedSmall > numberInstances / 2) + { + error = "Model contains too many prims smaller than " + PrimScaleMin.ToString() + + "m minimum allowed size. Please check scalling"; + return false; + } + else + warning += skipedSmall.ToString() + " of the requested " +numberInstances.ToString() + + " model prims will not upload because they are smaller than " + PrimScaleMin.ToString() + + "m minimum allowed size. Please check scalling "; } if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) @@ -403,9 +412,14 @@ namespace OpenSim.Region.ClientStack.Linden submesh_offset = -1; - if (map.ContainsKey("physics_mesh")) - { + tmpmap = null; + if(map.ContainsKey("physics_mesh")) tmpmap = (OSDMap)map["physics_mesh"]; + else if (map.ContainsKey("physics_shape")) // old naming + tmpmap = (OSDMap)map["physics_shape"]; + + if(tmpmap != null) + { if (tmpmap.ContainsKey("offset")) submesh_offset = tmpmap["offset"].AsInteger() + start; if (tmpmap.ContainsKey("size")) -- cgit v1.1 From 68ece236a6cd8a2a9bc009287e43debdc6e9a79d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 23 Sep 2012 23:55:28 +0200 Subject: Protect the responses map with a lock. Also remove ugly "this." type of member notation. --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 14 ++++++----- .../Linden/Caps/WebFetchInvDescModule.cs | 28 ++++++++++++---------- 2 files changed, 24 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 0ac56ec..2000279 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -146,14 +146,14 @@ namespace OpenSim.Region.ClientStack.Linden { m_scene = scene; - HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; + HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; GetEvents = (x, y, s) => { lock (responses) { try { - return this.responses[x]; + return responses[x]; } finally { @@ -165,15 +165,15 @@ namespace OpenSim.Region.ClientStack.Linden Request = (x, y) => { y["RequestID"] = x.ToString(); - lock (this.requests) - this.requests.Add(y); + lock (requests) + requests.Add(y); m_queue.Enqueue(this); }; NoEvents = (x, y) => { - lock (this.requests) + lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); @@ -198,7 +198,7 @@ namespace OpenSim.Region.ClientStack.Linden try { - lock (this.requests) + lock (requests) { request = requests[0]; requests.RemoveAt(0); @@ -221,8 +221,10 @@ namespace OpenSim.Region.ClientStack.Linden response["content_type"] = "text/plain"; response["keepalive"] = false; response["reusecontext"] = false; + lock (responses) responses[requestID] = response; + return; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 4908c2c..f76ea74 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -144,31 +144,34 @@ namespace OpenSim.Region.ClientStack.Linden public PollServiceInventoryEventArgs(UUID pId) : base(null, null, null, null, pId, 30000) { - HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; + HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; GetEvents = (x, y, s) => { - try + lock (responses) { - return this.responses[x]; - } - finally - { - responses.Remove(x); + try + { + return responses[x]; + } + finally + { + responses.Remove(x); + } } }; Request = (x, y) => { y["RequestID"] = x.ToString(); - lock (this.requests) - this.requests.Add(y); + lock (requests) + requests.Add(y); m_queue.Enqueue(this); }; NoEvents = (x, y) => { - lock (this.requests) + lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); @@ -192,7 +195,7 @@ namespace OpenSim.Region.ClientStack.Linden try { - lock (this.requests) + lock (requests) { request = requests[0]; requests.RemoveAt(0); @@ -214,7 +217,8 @@ namespace OpenSim.Region.ClientStack.Linden response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null); - responses[requestID] = response; + lock (responses) + responses[requestID] = response; } } -- cgit v1.1 From a1a0a90720e65ce104699abb6dcd46b5cb34a6db Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 24 Sep 2012 22:57:33 +0100 Subject: more upload changes (plus untouch prebuild.xml) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 183 ++++++++++++++------- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 13 +- 2 files changed, 128 insertions(+), 68 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 21a1005..4a323d8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -118,12 +118,20 @@ namespace OpenSim.Region.ClientStack.Linden private IAssetService m_assetService; private bool m_dumpAssetsToFile = false; private string m_regionName; + private int m_levelUpload = 0; - private float m_PrimScaleMin = 0.001f; - private bool m_enableFreeTestUpload = false; - private bool m_enableModelUploadTextureToInventory = false; + + private bool m_enableFreeTestUpload = false; // allows "TEST-" prefix hack + private bool m_ForceFreeTestUpload = false; // forces all uploads to be test + + private bool m_enableModelUploadTextureToInventory = false; // place uploaded textures also in inventory + // may not be visible till relog + + private bool m_RestrictFreeTestUploadPerms = false; // reduces also the permitions. Needs a creator defined!! private UUID m_testAssetsCreatorID = UUID.Zero; + private float m_PrimScaleMin = 0.001f; + private enum FileAgentInventoryState : int { idle = 0, @@ -143,16 +151,16 @@ namespace OpenSim.Region.ClientStack.Linden // tell it about scene object limits m_ModelCost.NonPhysicalPrimScaleMax = m_Scene.m_maxNonphys; m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys; -// m_ModelCost.PrimScaleMin = ?? + // m_ModelCost.ObjectLinkedPartsMax = ?? -// m_PrimScaleMin = ?? +// m_ModelCost.PrimScaleMin = ?? + m_PrimScaleMin = m_ModelCost.PrimScaleMin; float modelTextureUploadFactor = m_ModelCost.ModelTextureCostFactor; float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; - - // can be UUID.zero. This is me at OSG, should be a valid grid ID, is case a bad config - UUID.TryParse("58e06f33-ea8c-4ff6-9af5-420606926118", out m_testAssetsCreatorID); + float modelPrimCreationCost = m_ModelCost.primCreationCost; + float modelMeshByteCost = m_ModelCost.bytecost; IConfigSource config = m_Scene.Config; if (config != null) @@ -175,10 +183,16 @@ namespace OpenSim.Region.ClientStack.Linden modelUploadFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", modelUploadFactor); modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); - m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", false); + // next 2 are normalized so final cost is afected by modelUploadFactor above and normal cost + modelPrimCreationCost = EconomyConfig.GetFloat("ModelPrimCreationCost", modelPrimCreationCost); + modelMeshByteCost = EconomyConfig.GetFloat("ModelMeshByteCost", modelMeshByteCost); - m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", false); - string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", m_testAssetsCreatorID.ToString()); + m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", m_enableModelUploadTextureToInventory); + + m_RestrictFreeTestUploadPerms = EconomyConfig.GetBoolean("m_RestrictFreeTestUploadPerms", m_RestrictFreeTestUploadPerms); + m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", m_enableFreeTestUpload); + m_ForceFreeTestUpload = EconomyConfig.GetBoolean("ForceFreeTestUpload", m_ForceFreeTestUpload); + string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", ""); if (testcreator != "") { UUID id; @@ -190,6 +204,8 @@ namespace OpenSim.Region.ClientStack.Linden m_ModelCost.ModelMeshCostFactor = modelUploadFactor; m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; + m_ModelCost.primCreationCost = modelPrimCreationCost; + m_ModelCost.bytecost = modelMeshByteCost; } } @@ -490,6 +506,8 @@ namespace OpenSim.Region.ClientStack.Linden int nreqinstances = 0; bool IsAtestUpload = false; + string assetName = llsdRequest.name; + LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || @@ -497,7 +515,7 @@ namespace OpenSim.Region.ClientStack.Linden llsdRequest.asset_type == "mesh" || llsdRequest.asset_type == "sound") { - ScenePresence avatar = null; + ScenePresence avatar = null; m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); // check user level @@ -519,7 +537,7 @@ namespace OpenSim.Region.ClientStack.Linden } } - // check funds + // check test upload and funds if (client != null) { IMoneyModule mm = m_Scene.RequestModuleInterface(); @@ -558,41 +576,53 @@ namespace OpenSim.Region.ClientStack.Linden cost = baseCost; } - if (m_enableFreeTestUpload && cost > 0 && mm != null) + if (cost > 0 && mm != null) { - string str = llsdRequest.name; - if (str.Length > 5 && str.StartsWith("TEST-")) + // check for test upload + + if (m_ForceFreeTestUpload) // all are test { - warning += "Upload will have no cost, but for personal test purposes only. Other uses are forbiden"; + if (!(assetName.Length > 5 && assetName.StartsWith("TEST-"))) // has normal name lets change it + assetName = "TEST-" + assetName; + IsAtestUpload = true; } - } - - if (client != null && warning != String.Empty) - client.SendAgentAlertMessage(warning, true); - // check funds - if (!IsAtestUpload && mm != null && cost >0) - { - if (!mm.UploadCovered(client.AgentId, (int)cost)) + else if (m_enableFreeTestUpload) // only if prefixed with "TEST-" { - LLSDAssetUploadError resperror = new LLSDAssetUploadError(); - resperror.message = "Insuficient funds"; - resperror.identifier = UUID.Zero; - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; - errorResponse.state = "error"; - errorResponse.error = resperror; - lock (m_ModelCost) - m_FileAgentInventoryState = FileAgentInventoryState.idle; - return errorResponse; + IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-")); + } + + + if(IsAtestUpload) // let user know, still showing cost estimation + warning += "Upload will have no cost, for personal test purposes only. Other uses are forbiden. Items may not work on another region"; + + // check funds + else + { + if (!mm.UploadCovered(client.AgentId, (int)cost)) + { + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = "Insuficient funds"; + resperror.identifier = UUID.Zero; + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + errorResponse.error = resperror; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; + return errorResponse; + } } } + + if (client != null && warning != String.Empty) + client.SendAgentAlertMessage(warning, true); } } - - string assetName = llsdRequest.name; + string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; UUID newAsset = UUID.Random(); @@ -607,7 +637,7 @@ namespace OpenSim.Region.ClientStack.Linden AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, - texturesFolder, nreqtextures, nreqmeshs, nreqinstances,IsAtestUpload); + texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -667,12 +697,16 @@ namespace OpenSim.Region.ClientStack.Linden sbyte assType = 0; sbyte inType = 0; + IClientAPI client = null; + UUID owner_id = m_HostCapsObj.AgentID; UUID creatorID; bool istest = IsAtestUpload && m_enableFreeTestUpload && (cost > 0); - if (istest) + bool restrictPerms = m_RestrictFreeTestUploadPerms && istest; + + if (istest && m_testAssetsCreatorID != UUID.Zero) creatorID = m_testAssetsCreatorID; else creatorID = owner_id; @@ -755,10 +789,19 @@ namespace OpenSim.Region.ClientStack.Linden List textures = new List(); + + if (doTextInv) + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + + if(client == null) // don't put textures in inventory if there is no client + doTextInv = false; + for (int i = 0; i < texture_list.Count; i++) { AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, creatorIDstr); textureAsset.Data = texture_list[i].AsBinary(); + if (istest) + textureAsset.Local = true; m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); @@ -788,9 +831,8 @@ namespace OpenSim.Region.ClientStack.Linden texitem.NextPermissions = (uint)PermissionMask.All; texitem.CreationDate = Util.UnixTimeSinceEpoch(); - AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); + m_Scene.AddInventoryItem(client, texitem); texitem = null; - // this aren't showing up in viewer until relog :( } } @@ -800,6 +842,8 @@ namespace OpenSim.Region.ClientStack.Linden { AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); meshAsset.Data = mesh_list[i].AsBinary(); + if (istest) + meshAsset.Local = true; m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); } @@ -908,14 +952,12 @@ namespace OpenSim.Region.ClientStack.Linden // UUID owner_id = permissions["owner_id"].AsUUID(); // int owner_mask = permissions["owner_mask"].AsInteger(); // no longer used - end ------------------------ - - + SceneObjectPart prim = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); prim.Scale = scale; -// prim.OffsetPosition = position; rotations.Add(rotation); positions.Add(position); prim.UUID = UUID.Random(); @@ -930,18 +972,20 @@ namespace OpenSim.Region.ClientStack.Linden else prim.Name = assetName + "#" + i.ToString(); - if (istest) + if (restrictPerms) { prim.BaseMask = (uint)(PermissionMask.Move | PermissionMask.Modify); prim.EveryoneMask = 0; prim.GroupMask = 0; prim.NextOwnerMask = 0; prim.OwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify); + } + if(istest) prim.Description = "For personal testing only. Other uses are forbiden"; - } else prim.Description = ""; + prim.Material = material; prim.PhysicsShapeType = physicsShapeType; @@ -1007,6 +1051,8 @@ namespace OpenSim.Region.ClientStack.Linden AssetBase asset; asset = new AssetBase(assetID, assetName, assType, creatorIDstr); asset.Data = data; + if (istest) + asset.Local = true; if (AddNewAsset != null) AddNewAsset(asset); else if (m_assetService != null) @@ -1019,7 +1065,10 @@ namespace OpenSim.Region.ClientStack.Linden item.ID = inventoryItem; item.AssetID = asset.FullID; if (istest) + { item.Description = "For personal testing only. Other uses are forbiden"; + item.Flags = (uint) (InventoryItemFlags.SharedSingleReference); + } else item.Description = assetDescription; item.Name = assetName; @@ -1030,7 +1079,7 @@ namespace OpenSim.Region.ClientStack.Linden // If we set PermissionMask.All then when we rez the item the next permissions will replace the current // (owner) permissions. This becomes a problem if next permissions are changed. - if (istest) + if (restrictPerms) { item.CurrentPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); @@ -1051,16 +1100,18 @@ namespace OpenSim.Region.ClientStack.Linden item.CreationDate = Util.UnixTimeSinceEpoch(); - IClientAPI client = null; m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); if (AddNewInventoryItem != null) { if (istest) { + m_Scene.AddInventoryItem(client, item); +/* AddNewInventoryItem(m_HostCapsObj.AgentID, item, 0); if (client != null) - client.SendAgentAlertMessage("Upload complete with no cost for personal testing purposes only. Other uses are forbiden", true); + client.SendAgentAlertMessage("Upload will have no cost, for personal test purposes only. Other uses are forbiden. Items may not work on a another region" , true); + */ } else { @@ -1487,22 +1538,34 @@ namespace OpenSim.Region.ClientStack.Linden handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, ref m_error); } - if(m_error == String.Empty) - { - uploadComplete.new_asset = newAssetID.ToString(); - uploadComplete.new_inventory_item = inv; -// if (m_texturesFolder != UUID.Zero) -// uploadComplete.new_texture_folder_id = m_texturesFolder; - uploadComplete.state = "complete"; - } - else + if (m_IsAtestUpload) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); - resperror.message = m_error; + resperror.message = "Upload SUCESSEFULL for testing purposes only. Other uses are forbiden. Item may not work on other region"; resperror.identifier = inv; uploadComplete.error = resperror; - uploadComplete.state = "failed"; + uploadComplete.state = "Upload4Testing"; + } + else + { + if (m_error == String.Empty) + { + uploadComplete.new_asset = newAssetID.ToString(); + uploadComplete.new_inventory_item = inv; + // if (m_texturesFolder != UUID.Zero) + // uploadComplete.new_texture_folder_id = m_texturesFolder; + uploadComplete.state = "complete"; + } + else + { + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = m_error; + resperror.identifier = inv; + + uploadComplete.error = resperror; + uploadComplete.state = "failed"; + } } res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 66bb429..4a3fae6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -35,18 +35,15 @@ namespace OpenSim.Region.ClientStack.Linden // fees are normalized to 1.0 // this parameters scale them to basic cost ( so 1.0 translates to 10 ) - public float ModelMeshCostFactor = 0f; //Free - public float ModelMinCostFactor = 0f; // Free - //public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) - //public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures + public float ModelMeshCostFactor = 0.0f; // scale total cost relative to basic (excluding textures) + public float ModelTextureCostFactor = 1.0f; // scale textures fee to basic. + public float ModelMinCostFactor = 0.0f; // 0.5f; // minimum total model free excluding textures - public float ModelTextureCostFactor = 1.00f; // keep full price because texture price - // is based on it's storage needs not on usability // itens costs in normalized values // ie will be multiplied by basicCost and factors above - const float primCreationCost = 0.002f; // extra cost for each prim creation overhead + public float primCreationCost = 0.002f; // extra cost for each prim creation overhead // weigthed size to normalized cost - const float bytecost = 1e-5f; + public float bytecost = 1e-5f; // mesh upload fees based on compressed data sizes // several data sections are counted more that once -- cgit v1.1 From 421071bd8a489b90d3ddd58add7135b178f59381 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 24 Sep 2012 23:19:57 +0200 Subject: Text changes for upload messages --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 4a323d8..c705f10 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -596,7 +596,7 @@ namespace OpenSim.Region.ClientStack.Linden if(IsAtestUpload) // let user know, still showing cost estimation - warning += "Upload will have no cost, for personal test purposes only. Other uses are forbiden. Items may not work on another region"; + warning += "Upload will have no cost, for testing purposes only. Other uses are prohibited. Items will not work after 48 hours or on other regions"; // check funds else @@ -982,7 +982,7 @@ namespace OpenSim.Region.ClientStack.Linden } if(istest) - prim.Description = "For personal testing only. Other uses are forbiden"; + prim.Description = "For testing only. Other uses are prohibited"; else prim.Description = ""; @@ -1066,7 +1066,7 @@ namespace OpenSim.Region.ClientStack.Linden item.AssetID = asset.FullID; if (istest) { - item.Description = "For personal testing only. Other uses are forbiden"; + item.Description = "For testing only. Other uses are prohibited"; item.Flags = (uint) (InventoryItemFlags.SharedSingleReference); } else @@ -1541,7 +1541,7 @@ namespace OpenSim.Region.ClientStack.Linden if (m_IsAtestUpload) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); - resperror.message = "Upload SUCESSEFULL for testing purposes only. Other uses are forbiden. Item may not work on other region"; + resperror.message = "Upload SUCESSEFULL for testing purposes only. Other uses are prohibited. Item will not work after 48 hours or on other regions"; resperror.identifier = inv; uploadComplete.error = resperror; -- cgit v1.1 From 2cb17d6fbb4cfc5157cec0f3e4589db007a117b3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Sep 2012 03:38:45 +0100 Subject: change GetTextureModule processing --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 60 +++++++++++----------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 2000279..1ccddd2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -53,6 +53,14 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetTextureModule")] public class GetTextureModule : INonSharedRegionModule { + + struct aPollRequest + { + public PollServiceTextureEventArgs thepoll; + public UUID reqID; + public Hashtable request; + } + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -64,8 +72,8 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_capsDict = new Dictionary(); private static Thread[] m_workerThreads = null; - private static OpenMetaverse.BlockingQueue m_queue = - new OpenMetaverse.BlockingQueue(); + private static OpenMetaverse.BlockingQueue m_queue = + new OpenMetaverse.BlockingQueue(); #region ISharedRegionModule Members @@ -104,7 +112,7 @@ namespace OpenSim.Region.ClientStack.Linden String.Format("TextureWorkerThread{0}", i), ThreadPriority.Normal, false, - true, + false, null, int.MaxValue); } @@ -129,7 +137,8 @@ namespace OpenSim.Region.ClientStack.Linden ~GetTextureModule() { foreach (Thread t in m_workerThreads) - t.Abort(); + Watchdog.AbortThread(t.ManagedThreadId); + } private class PollServiceTextureEventArgs : PollServiceEventArgs @@ -142,7 +151,12 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_scene; public PollServiceTextureEventArgs(UUID pId, Scene scene) : - base(null, null, null, null, pId, 30000) + base(null, null, null, null, pId, int.MaxValue) + // this should never timeout + // each request must be processed and return a response + // noevents can possible be use for nice shutdown, but not sure now + // the execution will provide a proper response even if it fails + { m_scene = scene; @@ -164,13 +178,15 @@ namespace OpenSim.Region.ClientStack.Linden Request = (x, y) => { - y["RequestID"] = x.ToString(); - lock (requests) - requests.Add(y); + aPollRequest reqinfo = new aPollRequest(); + reqinfo.thepoll = this; + reqinfo.reqID = x; + reqinfo.request = y; - m_queue.Enqueue(this); + m_queue.Enqueue(reqinfo); }; + // this should never happen except possible on shutdown NoEvents = (x, y) => { lock (requests) @@ -191,27 +207,14 @@ namespace OpenSim.Region.ClientStack.Linden }; } - public void Process() + public void Process(aPollRequest requestinfo) { Hashtable response; - Hashtable request = null; - try - { - lock (requests) - { - request = requests[0]; - requests.RemoveAt(0); - } - } - catch - { - return; - } - - UUID requestID = new UUID(request["RequestID"].ToString()); + UUID requestID = requestinfo.reqID; // If the avatar is gone, don't bother to get the texture + if (m_scene.GetScenePresence(Id) == null) { response = new Hashtable(); @@ -228,7 +231,7 @@ namespace OpenSim.Region.ClientStack.Linden return; } - response = m_getTextureHandler.Handle(request); + response = m_getTextureHandler.Handle(requestinfo.request); lock (responses) responses[requestID] = response; } @@ -275,11 +278,10 @@ namespace OpenSim.Region.ClientStack.Linden { while (true) { - PollServiceTextureEventArgs args = m_queue.Dequeue(); + aPollRequest poolreq = m_queue.Dequeue(); - args.Process(); + poolreq.thepoll.Process(poolreq); } } } - } -- cgit v1.1 From 4d681bfde617371bf14fb74da595887a33ec688b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Sep 2012 03:59:19 +0100 Subject: do the same to webFecthInvDescModule --- .../Linden/Caps/WebFetchInvDescModule.cs | 58 ++++++++++------------ 1 file changed, 25 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index f76ea74..0f305b1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -52,6 +52,13 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class WebFetchInvDescModule : INonSharedRegionModule { + struct aPollRequest + { + public PollServiceInventoryEventArgs thepoll; + public UUID reqID; + public Hashtable request; + } + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -64,8 +71,8 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_capsDict = new Dictionary(); private static Thread[] m_workerThreads = null; - private static OpenMetaverse.BlockingQueue m_queue = - new OpenMetaverse.BlockingQueue(); + private static OpenMetaverse.BlockingQueue m_queue = + new OpenMetaverse.BlockingQueue(); #region ISharedRegionModule Members @@ -131,18 +138,16 @@ namespace OpenSim.Region.ClientStack.Linden ~WebFetchInvDescModule() { foreach (Thread t in m_workerThreads) - t.Abort(); + Watchdog.AbortThread(t.ManagedThreadId); } private class PollServiceInventoryEventArgs : PollServiceEventArgs { - private List requests = - new List(); private Dictionary responses = new Dictionary(); public PollServiceInventoryEventArgs(UUID pId) : - base(null, null, null, null, pId, 30000) + base(null, null, null, null, pId, int.MaxValue) { HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; GetEvents = (x, y, s) => @@ -162,21 +167,23 @@ namespace OpenSim.Region.ClientStack.Linden Request = (x, y) => { - y["RequestID"] = x.ToString(); - lock (requests) - requests.Add(y); + aPollRequest reqinfo = new aPollRequest(); + reqinfo.thepoll = this; + reqinfo.reqID = x; + reqinfo.request = y; - m_queue.Enqueue(this); + m_queue.Enqueue(reqinfo); }; NoEvents = (x, y) => { +/* lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); } - +*/ Hashtable response = new Hashtable(); response["int_response_code"] = 500; @@ -189,24 +196,9 @@ namespace OpenSim.Region.ClientStack.Linden }; } - public void Process() + public void Process(aPollRequest requestinfo) { - Hashtable request = null; - - try - { - lock (requests) - { - request = requests[0]; - requests.RemoveAt(0); - } - } - catch - { - return; - } - - UUID requestID = new UUID(request["RequestID"].ToString()); + UUID requestID = requestinfo.reqID; Hashtable response = new Hashtable(); @@ -215,7 +207,8 @@ namespace OpenSim.Region.ClientStack.Linden response["keepalive"] = false; response["reusecontext"] = false; - response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null); + response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( + requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); lock (responses) responses[requestID] = response; @@ -226,8 +219,7 @@ namespace OpenSim.Region.ClientStack.Linden { string capUrl = "/CAPS/" + UUID.Random() + "/"; - // Register this as a poll service - // absurd large timeout to tune later to make a bit less than viewer + // Register this as a poll service PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); args.Type = PollServiceEventArgs.EventType.Inventory; @@ -263,9 +255,9 @@ namespace OpenSim.Region.ClientStack.Linden { while (true) { - PollServiceInventoryEventArgs args = m_queue.Dequeue(); + aPollRequest poolreq = m_queue.Dequeue(); - args.Process(); + poolreq.thepoll.Process(poolreq); } } } -- cgit v1.1 From ef3d44240ef0f4fe714ff0ea76a89be1e23fcb4e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Sep 2012 04:03:15 +0100 Subject: missed change --- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 1ccddd2..b16076d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -189,12 +189,13 @@ namespace OpenSim.Region.ClientStack.Linden // this should never happen except possible on shutdown NoEvents = (x, y) => { +/* lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); } - +*/ Hashtable response = new Hashtable(); response["int_response_code"] = 500; -- cgit v1.1 From 654dd289f263a4eef4f2aa70a1cb8d289ec7e04c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 03:05:27 +0100 Subject: more changes to PollService --- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 7 ++++++- OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index b16076d..8a607fb 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -160,7 +160,11 @@ namespace OpenSim.Region.ClientStack.Linden { m_scene = scene; - HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; + HasEvents = (x, y) => + { + lock (responses) + return responses.ContainsKey(x); + }; GetEvents = (x, y, s) => { lock (responses) @@ -247,6 +251,7 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene); args.Type = PollServiceEventArgs.EventType.Texture; + args.GetEventsNeedsRequest = false; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); string hostName = m_scene.RegionInfo.ExternalHostName; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 0f305b1..56070c6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -223,6 +223,7 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); args.Type = PollServiceEventArgs.EventType.Inventory; + args.GetEventsNeedsRequest = false; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); string hostName = m_scene.RegionInfo.ExternalHostName; -- cgit v1.1 From 7e3eba1064197024690c5b3cae4c2cf87319e48c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 15:41:57 +0100 Subject: Seems nothing actually need the request body for getevents. so change control flag to false --- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 12 ++---------- .../Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 1 - 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 8a607fb..5169f65 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -151,12 +151,7 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_scene; public PollServiceTextureEventArgs(UUID pId, Scene scene) : - base(null, null, null, null, pId, int.MaxValue) - // this should never timeout - // each request must be processed and return a response - // noevents can possible be use for nice shutdown, but not sure now - // the execution will provide a proper response even if it fails - + base(null, null, null, null, pId, int.MaxValue) { m_scene = scene; @@ -219,7 +214,6 @@ namespace OpenSim.Region.ClientStack.Linden UUID requestID = requestinfo.reqID; // If the avatar is gone, don't bother to get the texture - if (m_scene.GetScenePresence(Id) == null) { response = new Hashtable(); @@ -246,12 +240,10 @@ namespace OpenSim.Region.ClientStack.Linden { string capUrl = "/CAPS/" + UUID.Random() + "/"; - // Register this as a poll service - // absurd large timeout to tune later to make a bit less than viewer + // Register this as a poll service PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene); args.Type = PollServiceEventArgs.EventType.Texture; - args.GetEventsNeedsRequest = false; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); string hostName = m_scene.RegionInfo.ExternalHostName; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 56070c6..0f305b1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -223,7 +223,6 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); args.Type = PollServiceEventArgs.EventType.Inventory; - args.GetEventsNeedsRequest = false; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); string hostName = m_scene.RegionInfo.ExternalHostName; -- cgit v1.1 From 617f1b9223375a2dda925e26c395901810d37697 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 16:17:49 +0100 Subject: just remove the damm thing --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 2 +- OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index ebfe687..e113c60 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -419,7 +419,7 @@ namespace OpenSim.Region.ClientStack.Linden } } - public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) + public Hashtable GetEvents(UUID requestID, UUID pAgentId) { if (DebugLevel >= 2) m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 5169f65..cc65981 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -160,7 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden lock (responses) return responses.ContainsKey(x); }; - GetEvents = (x, y, s) => + GetEvents = (x, y) => { lock (responses) { diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 0f305b1..0caeddf 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -150,7 +150,7 @@ namespace OpenSim.Region.ClientStack.Linden base(null, null, null, null, pId, int.MaxValue) { HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; - GetEvents = (x, y, s) => + GetEvents = (x, y) => { lock (responses) { -- cgit v1.1 From de3ff44406943ffad5832b6b0434209a8fabc298 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 14 Oct 2012 17:10:26 +0200 Subject: Make texture sedning use only two threads to make things less harsh on bandwidth --- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index cc65981..d1a1583 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -104,9 +104,9 @@ namespace OpenSim.Region.ClientStack.Linden if (m_workerThreads == null) { - m_workerThreads = new Thread[4]; + m_workerThreads = new Thread[2]; - for (uint i = 0; i < 4; i++) + for (uint i = 0; i < 2; i++) { m_workerThreads[i] = Watchdog.StartThread(DoTextureRequests, String.Format("TextureWorkerThread{0}", i), -- cgit v1.1 From 322eefbb6f6c3cc418a327a3b51357a12ee5036f Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 17 Oct 2012 01:31:05 +0200 Subject: Allow the console to be used by gods as well as region owners. --- OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs index 413536d..0a5ad0f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs @@ -104,7 +104,7 @@ namespace OpenSim.Region.ClientStack.Linden public void RegisterCaps(UUID agentID, Caps caps) { - if (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(agentID)) + if (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(agentID) && !m_scene.Permissions.IsGod(agentID)) return; UUID capID = UUID.Random(); -- cgit v1.1 From 2e8e8d576e342e4036b278805137ad68066dcbad Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 18 Oct 2012 13:20:50 +0200 Subject: Remove redundant and annoyingly modal message box in upload processing. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index c705f10..650cd50 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1116,17 +1116,17 @@ namespace OpenSim.Region.ClientStack.Linden else { AddNewInventoryItem(m_HostCapsObj.AgentID, item, (uint)cost); - if (client != null) - { - // let users see anything.. i don't so far - string str; - if (cost > 0) - // dont remember where is money unit name to put here - str = "Upload complete. charged " + cost.ToString() + "$"; - else - str = "Upload complete"; - client.SendAgentAlertMessage(str, true); - } +// if (client != null) +// { +// // let users see anything.. i don't so far +// string str; +// if (cost > 0) +// // dont remember where is money unit name to put here +// str = "Upload complete. charged " + cost.ToString() + "$"; +// else +// str = "Upload complete"; +// client.SendAgentAlertMessage(str, true); +// } } } -- cgit v1.1 From 4fa088bafb4c78ad3177b0e944a4312bd6abdea7 Mon Sep 17 00:00:00 2001 From: teravus Date: Sun, 4 Nov 2012 22:57:24 -0500 Subject: Pipe Throttle Update Event to EventManager, client --> ScenePresence --> EventManager, so that modules can know when throttles are updated. The event contains no client specific data to preserve the possibility of 'multiple clients' and you must still call ControllingClient.GetThrottlesPacked(f) to see what the throttles actually are once the event fires. Hook EventManager.OnUpdateThrottle to GetTextureModule. --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index d1a1583..19d4b91 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -91,6 +91,7 @@ namespace OpenSim.Region.ClientStack.Linden { m_scene.EventManager.OnRegisterCaps -= RegisterCaps; m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; + m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate; m_scene = null; } @@ -101,6 +102,7 @@ namespace OpenSim.Region.ClientStack.Linden m_scene.EventManager.OnRegisterCaps += RegisterCaps; m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; + m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate; if (m_workerThreads == null) { @@ -118,6 +120,46 @@ namespace OpenSim.Region.ClientStack.Linden } } } + private int ExtractImageThrottle(byte[] pthrottles) + { + + byte[] adjData; + int pos = 0; + + if (!BitConverter.IsLittleEndian) + { + byte[] newData = new byte[7 * 4]; + Buffer.BlockCopy(pthrottles, 0, newData, 0, 7 * 4); + + for (int i = 0; i < 7; i++) + Array.Reverse(newData, i * 4, 4); + + adjData = newData; + } + else + { + adjData = pthrottles; + } + + // 0.125f converts from bits to bytes + //int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; + // int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; + // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; + // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; + // int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; + pos = pos + 16; + int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; + //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + return texture; + } + + // Now we know when the throttle is changed by the client in the case of a root agent or by a neighbor region in the case of a child agent. + public void ThrottleUpdate(ScenePresence p) + { + byte[] throttles = p.ControllingClient.GetThrottlesPacked(1); + UUID user = p.UUID; + int imagethrottle = ExtractImageThrottle(throttles); + } public void PostInitialise() { -- cgit v1.1 From b7b96a5e4f1e26341742e35e5253e6e14797bd15 Mon Sep 17 00:00:00 2001 From: teravus Date: Mon, 5 Nov 2012 13:10:00 -0500 Subject: Another step in the chain. Pipe the throttle update to the appropriate PollServiceTextureEventArgs. Each poll service having it's own throttle member is more consistent with the model then the region module keeping track of all of them globally and better for locking too. The Poll Services object is not set static to handle multiple nearby regions on the same simulator. Next step is hooking it up to HasEvents --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 47 ++++++++++++++++------ 1 file changed, 35 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 19d4b91..4bfdbff 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -61,6 +61,13 @@ namespace OpenSim.Region.ClientStack.Linden public Hashtable request; } + public struct aPollResponse + { + public Hashtable response; + public int bytes; + } + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -75,6 +82,8 @@ namespace OpenSim.Region.ClientStack.Linden private static OpenMetaverse.BlockingQueue m_queue = new OpenMetaverse.BlockingQueue(); + private Dictionary m_pollservices = new Dictionary(); + #region ISharedRegionModule Members public void Initialise(IConfigSource source) @@ -147,7 +156,7 @@ namespace OpenSim.Region.ClientStack.Linden // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; // int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - pos = pos + 16; + pos = pos + 20; int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); return texture; @@ -159,6 +168,11 @@ namespace OpenSim.Region.ClientStack.Linden byte[] throttles = p.ControllingClient.GetThrottlesPacked(1); UUID user = p.UUID; int imagethrottle = ExtractImageThrottle(throttles); + PollServiceTextureEventArgs args; + if (m_pollservices.TryGetValue(user,out args)) + { + args.UpdateThrottle(imagethrottle); + } } public void PostInitialise() @@ -187,8 +201,8 @@ namespace OpenSim.Region.ClientStack.Linden { private List requests = new List(); - private Dictionary responses = - new Dictionary(); + private Dictionary responses = + new Dictionary(); private Scene m_scene; @@ -196,7 +210,7 @@ namespace OpenSim.Region.ClientStack.Linden base(null, null, null, null, pId, int.MaxValue) { m_scene = scene; - + // x is request id, y is userid HasEvents = (x, y) => { lock (responses) @@ -208,7 +222,7 @@ namespace OpenSim.Region.ClientStack.Linden { try { - return responses[x]; + return responses[x].response; } finally { @@ -216,14 +230,14 @@ namespace OpenSim.Region.ClientStack.Linden } } }; - + // x is request id, y is request data hashtable Request = (x, y) => { aPollRequest reqinfo = new aPollRequest(); reqinfo.thepoll = this; reqinfo.reqID = x; reqinfo.request = y; - + m_queue.Enqueue(reqinfo); }; @@ -265,16 +279,21 @@ namespace OpenSim.Region.ClientStack.Linden response["content_type"] = "text/plain"; response["keepalive"] = false; response["reusecontext"] = false; - + lock (responses) - responses[requestID] = response; + responses[requestID] = new aPollResponse() {bytes = 0,response = response}; return; } response = m_getTextureHandler.Handle(requestinfo.request); lock (responses) - responses[requestID] = response; + responses[requestID] = new aPollResponse() { bytes = (int)response["int_bytes"], response = response}; + } + + internal void UpdateThrottle(int pimagethrottle) + { + } } @@ -299,19 +318,23 @@ namespace OpenSim.Region.ClientStack.Linden protocol = "https"; } caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); - + m_pollservices.Add(agentID, args); m_capsDict[agentID] = capUrl; } private void DeregisterCaps(UUID agentID, Caps caps) { string capUrl; - + PollServiceTextureEventArgs args; if (m_capsDict.TryGetValue(agentID, out capUrl)) { MainServer.Instance.RemoveHTTPHandler("", capUrl); m_capsDict.Remove(agentID); } + if (m_pollservices.TryGetValue(agentID, out args)) + { + m_pollservices.Remove(agentID); + } } private void DoTextureRequests() -- cgit v1.1 From 182b4872437e97762ac494dbf1815fe63aa29405 Mon Sep 17 00:00:00 2001 From: teravus Date: Mon, 5 Nov 2012 22:05:10 -0500 Subject: This implements the Caps throttler. After some testing, the system seemed to be OK with me specifying allowing 1 oversized image per 70,000b/sec with at least one. Try it out, start with a low bandwidth setting and then, set your bandwidth setting middle/high and see the difference. Tested with Two Clients on a region with 1800 textures all visible at once. --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 119 ++++++++++++++++++--- 1 file changed, 106 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 4bfdbff..8cba6c8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.ClientStack.Linden public Hashtable request; } - public struct aPollResponse + public class aPollResponse { public Hashtable response; public int bytes; @@ -151,13 +151,18 @@ namespace OpenSim.Region.ClientStack.Linden } // 0.125f converts from bits to bytes - //int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - // int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; - // int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; + //int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + //pos += 4; + // int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + //pos += 4; + // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + // pos += 4; + // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + // pos += 4; + // int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + // pos += 4; pos = pos + 20; - int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; + int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); //pos += 4; //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); return texture; } @@ -205,7 +210,7 @@ namespace OpenSim.Region.ClientStack.Linden new Dictionary(); private Scene m_scene; - + private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000); public PollServiceTextureEventArgs(UUID pId, Scene scene) : base(null, null, null, null, pId, int.MaxValue) { @@ -214,7 +219,12 @@ namespace OpenSim.Region.ClientStack.Linden HasEvents = (x, y) => { lock (responses) - return responses.ContainsKey(x); + { + bool ret = m_throttler.hasEvents(x, responses); + m_throttler.ProcessTime(); + return ret; + + } }; GetEvents = (x, y) => { @@ -281,19 +291,27 @@ namespace OpenSim.Region.ClientStack.Linden response["reusecontext"] = false; lock (responses) - responses[requestID] = new aPollResponse() {bytes = 0,response = response}; + responses[requestID] = new aPollResponse() {bytes = 0, response = response}; return; } - + response = m_getTextureHandler.Handle(requestinfo.request); lock (responses) - responses[requestID] = new aPollResponse() { bytes = (int)response["int_bytes"], response = response}; + { + responses[requestID] = new aPollResponse() + { + bytes = (int) response["int_bytes"], + response = response + }; + + } + m_throttler.ProcessTime(); } internal void UpdateThrottle(int pimagethrottle) { - + m_throttler.ThrottleBytes = pimagethrottle; } } @@ -347,4 +365,79 @@ namespace OpenSim.Region.ClientStack.Linden } } } + + internal sealed class CapsDataThrottler + { + + private volatile int currenttime = 0; + private volatile int lastTimeElapsed = 0; + private volatile int BytesSent = 0; + private int oversizedImages = 0; + public CapsDataThrottler(int pBytes, int max, int min) + { + ThrottleBytes = pBytes; + lastTimeElapsed = Util.EnvironmentTickCount(); + } + public bool hasEvents(UUID key, Dictionary responses) + { + PassTime(); + // Note, this is called IN LOCK + bool haskey = responses.ContainsKey(key); + if (!haskey) + { + return false; + } + GetTextureModule.aPollResponse response; + if (responses.TryGetValue(key,out response)) + { + + // Normal + if (BytesSent + response.bytes <= ThrottleBytes) + { + BytesSent += response.bytes; + //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; + //m_actions.Add(timeBasedAction); + return true; + } + // Big textures + else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes%50000) + 1)) + { + Interlocked.Increment(ref oversizedImages); + BytesSent += response.bytes; + //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; + //m_actions.Add(timeBasedAction); + return true; + } + else + { + return false; + } + } + + return haskey; + } + public void ProcessTime() + { + PassTime(); + } + + + private void PassTime() + { + currenttime = Util.EnvironmentTickCount(); + int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); + //processTimeBasedActions(responses); + if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) + { + lastTimeElapsed = Util.EnvironmentTickCount(); + BytesSent -= ThrottleBytes; + if (BytesSent < 0) BytesSent = 0; + if (BytesSent < ThrottleBytes) + { + oversizedImages = 0; + } + } + } + public int ThrottleBytes; + } } -- cgit v1.1 From cda127e30f0049cda21137363e4d759fd7fd4959 Mon Sep 17 00:00:00 2001 From: teravus Date: Fri, 9 Nov 2012 23:55:30 -0500 Subject: * Prep work switching the GetMeshModule over to a poll service. * This still has the image throttler in it.. as is... so it's not suitable for live yet.... The throttler keeps track of the task throttle but doesn't balance the UDP throttle yet. --- .../ClientStack/Linden/Caps/GetMeshModule.cs | 362 ++++++++++++++++++++- .../ClientStack/Linden/Caps/GetTextureModule.cs | 121 +++---- 2 files changed, 410 insertions(+), 73 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 0d7b1fc..8deff81 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -27,11 +27,14 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Collections.Specialized; using System.Reflection; using System.IO; +using System.Threading; using System.Web; using Mono.Addins; +using OpenSim.Framework.Monitoring; using log4net; using Nini.Config; using OpenMetaverse; @@ -57,8 +60,42 @@ namespace OpenSim.Region.ClientStack.Linden private IAssetService m_AssetService; private bool m_Enabled = true; private string m_URL; + struct aPollRequest + { + public PollServiceMeshEventArgs thepoll; + public UUID reqID; + public Hashtable request; + } + + public class aPollResponse + { + public Hashtable response; + public int bytes; + } + + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static GetMeshHandler m_getMeshHandler; + + private IAssetService m_assetService = null; + + private Dictionary m_capsDict = new Dictionary(); + private static Thread[] m_workerThreads = null; + + private static OpenMetaverse.BlockingQueue m_queue = + new OpenMetaverse.BlockingQueue(); + + private Dictionary m_pollservices = new Dictionary(); - #region IRegionModuleBase Members + #region ISharedRegionModule Members + + ~GetMeshModule() + { + foreach (Thread t in m_workerThreads) + Watchdog.AbortThread(t.ManagedThreadId); + + } public Type ReplaceableInterface { @@ -83,6 +120,8 @@ namespace OpenSim.Region.ClientStack.Linden return; m_scene = pScene; + + m_assetService = pScene.AssetService; } public void RemoveRegion(Scene scene) @@ -91,6 +130,9 @@ namespace OpenSim.Region.ClientStack.Linden return; m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; + m_scene.EventManager.OnThrottleUpdate -= ThrottleUpdate; + m_scene = null; } @@ -101,6 +143,27 @@ namespace OpenSim.Region.ClientStack.Linden m_AssetService = m_scene.RequestModuleInterface(); m_scene.EventManager.OnRegisterCaps += RegisterCaps; + // We'll reuse the same handler for all requests. + m_getMeshHandler = new GetMeshHandler(m_assetService); + m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; + m_scene.EventManager.OnThrottleUpdate += ThrottleUpdate; + + if (m_workerThreads == null) + { + m_workerThreads = new Thread[2]; + + for (uint i = 0; i < 2; i++) + { + m_workerThreads[i] = Watchdog.StartThread(DoMeshRequests, + String.Format("MeshWorkerThread{0}", i), + ThreadPriority.Normal, + false, + false, + null, + int.MaxValue); + } + } + } @@ -110,25 +173,209 @@ namespace OpenSim.Region.ClientStack.Linden #endregion + private void DoMeshRequests() + { + while (true) + { + aPollRequest poolreq = m_queue.Dequeue(); + + poolreq.thepoll.Process(poolreq); + } + } + + // Now we know when the throttle is changed by the client in the case of a root agent or by a neighbor region in the case of a child agent. + public void ThrottleUpdate(ScenePresence p) + { + byte[] throttles = p.ControllingClient.GetThrottlesPacked(1); + UUID user = p.UUID; + int imagethrottle = ExtractTaskThrottle(throttles); + PollServiceMeshEventArgs args; + if (m_pollservices.TryGetValue(user, out args)) + { + args.UpdateThrottle(imagethrottle); + } + } + + private int ExtractTaskThrottle(byte[] pthrottles) + { + + byte[] adjData; + int pos = 0; + + if (!BitConverter.IsLittleEndian) + { + byte[] newData = new byte[7 * 4]; + Buffer.BlockCopy(pthrottles, 0, newData, 0, 7 * 4); + + for (int i = 0; i < 7; i++) + Array.Reverse(newData, i * 4, 4); + + adjData = newData; + } + else + { + adjData = pthrottles; + } + + // 0.125f converts from bits to bytes + //int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + //pos += 4; + // int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + //pos += 4; + // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + // pos += 4; + // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + // pos += 4; + pos += 16; + int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + // pos += 4; + //int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); //pos += 4; + //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); + return task; + } + + private class PollServiceMeshEventArgs : PollServiceEventArgs + { + private List requests = + new List(); + private Dictionary responses = + new Dictionary(); + + private Scene m_scene; + private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000, 10000); + public PollServiceMeshEventArgs(UUID pId, Scene scene) : + base(null, null, null, null, pId, int.MaxValue) + { + m_scene = scene; + // x is request id, y is userid + HasEvents = (x, y) => + { + lock (responses) + { + bool ret = m_throttler.hasEvents(x, responses); + m_throttler.ProcessTime(); + return ret; + + } + }; + GetEvents = (x, y) => + { + lock (responses) + { + try + { + return responses[x].response; + } + finally + { + responses.Remove(x); + } + } + }; + // x is request id, y is request data hashtable + Request = (x, y) => + { + aPollRequest reqinfo = new aPollRequest(); + reqinfo.thepoll = this; + reqinfo.reqID = x; + reqinfo.request = y; + + m_queue.Enqueue(reqinfo); + }; + + // this should never happen except possible on shutdown + NoEvents = (x, y) => + { + /* + lock (requests) + { + Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); + requests.Remove(request); + } + */ + Hashtable response = new Hashtable(); + + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + return response; + }; + } + + public void Process(aPollRequest requestinfo) + { + Hashtable response; + + UUID requestID = requestinfo.reqID; + + // If the avatar is gone, don't bother to get the texture + if (m_scene.GetScenePresence(Id) == null) + { + response = new Hashtable(); + + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + lock (responses) + responses[requestID] = new aPollResponse() { bytes = 0, response = response }; + + return; + } + + response = m_getMeshHandler.Handle(requestinfo.request); + lock (responses) + { + responses[requestID] = new aPollResponse() + { + bytes = (int)response["int_bytes"], + response = response + }; + + } + m_throttler.ProcessTime(); + } + + internal void UpdateThrottle(int pimagethrottle) + { + m_throttler.ThrottleBytes = pimagethrottle; + } + } public void RegisterCaps(UUID agentID, Caps caps) { // UUID capID = UUID.Random(); - - //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); if (m_URL == "localhost") { -// m_log.DebugFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); - GetMeshHandler gmeshHandler = new GetMeshHandler(m_AssetService); - IRequestHandler reqHandler - = new RestHTTPHandler( - "GET", - "/CAPS/" + UUID.Random(), - httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null), - "GetMesh", - agentID.ToString()); + string capUrl = "/CAPS/" + UUID.Random() + "/"; + + // Register this as a poll service + PollServiceMeshEventArgs args = new PollServiceMeshEventArgs(agentID, m_scene); + + args.Type = PollServiceEventArgs.EventType.Mesh; + MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); + + string hostName = m_scene.RegionInfo.ExternalHostName; + uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; + string protocol = "http"; - caps.RegisterHandler("GetMesh", reqHandler); + if (MainServer.Instance.UseSSL) + { + hostName = MainServer.Instance.SSLCommonName; + port = MainServer.Instance.SSLPort; + protocol = "https"; + } + caps.RegisterHandler("GetMesh", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); + m_pollservices.Add(agentID, args); + m_capsDict[agentID] = capUrl; + + + } else { @@ -136,6 +383,95 @@ namespace OpenSim.Region.ClientStack.Linden caps.RegisterHandler("GetMesh", m_URL); } } + private void DeregisterCaps(UUID agentID, Caps caps) + { + string capUrl; + PollServiceMeshEventArgs args; + if (m_capsDict.TryGetValue(agentID, out capUrl)) + { + MainServer.Instance.RemoveHTTPHandler("", capUrl); + m_capsDict.Remove(agentID); + } + if (m_pollservices.TryGetValue(agentID, out args)) + { + m_pollservices.Remove(agentID); + } + } + + internal sealed class CapsDataThrottler + { + + private volatile int currenttime = 0; + private volatile int lastTimeElapsed = 0; + private volatile int BytesSent = 0; + private int oversizedImages = 0; + public CapsDataThrottler(int pBytes, int max, int min) + { + ThrottleBytes = pBytes; + lastTimeElapsed = Util.EnvironmentTickCount(); + } + public bool hasEvents(UUID key, Dictionary responses) + { + PassTime(); + // Note, this is called IN LOCK + bool haskey = responses.ContainsKey(key); + if (!haskey) + { + return false; + } + aPollResponse response; + if (responses.TryGetValue(key, out response)) + { + + // Normal + if (BytesSent + response.bytes <= ThrottleBytes) + { + BytesSent += response.bytes; + //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; + //m_actions.Add(timeBasedAction); + return true; + } + // Big textures + else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes % 50000) + 1)) + { + Interlocked.Increment(ref oversizedImages); + BytesSent += response.bytes; + //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; + //m_actions.Add(timeBasedAction); + return true; + } + else + { + return false; + } + } + + return haskey; + } + public void ProcessTime() + { + PassTime(); + } + + + private void PassTime() + { + currenttime = Util.EnvironmentTickCount(); + int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); + //processTimeBasedActions(responses); + if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) + { + lastTimeElapsed = Util.EnvironmentTickCount(); + BytesSent -= ThrottleBytes; + if (BytesSent < 0) BytesSent = 0; + if (BytesSent < ThrottleBytes) + { + oversizedImages = 0; + } + } + } + public int ThrottleBytes; + } } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 8cba6c8..c8c709a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -364,80 +364,81 @@ namespace OpenSim.Region.ClientStack.Linden poolreq.thepoll.Process(poolreq); } } - } - - internal sealed class CapsDataThrottler - { - - private volatile int currenttime = 0; - private volatile int lastTimeElapsed = 0; - private volatile int BytesSent = 0; - private int oversizedImages = 0; - public CapsDataThrottler(int pBytes, int max, int min) - { - ThrottleBytes = pBytes; - lastTimeElapsed = Util.EnvironmentTickCount(); - } - public bool hasEvents(UUID key, Dictionary responses) + internal sealed class CapsDataThrottler { - PassTime(); - // Note, this is called IN LOCK - bool haskey = responses.ContainsKey(key); - if (!haskey) + + private volatile int currenttime = 0; + private volatile int lastTimeElapsed = 0; + private volatile int BytesSent = 0; + private int oversizedImages = 0; + public CapsDataThrottler(int pBytes, int max, int min) { - return false; + ThrottleBytes = pBytes; + lastTimeElapsed = Util.EnvironmentTickCount(); } - GetTextureModule.aPollResponse response; - if (responses.TryGetValue(key,out response)) + public bool hasEvents(UUID key, Dictionary responses) { - - // Normal - if (BytesSent + response.bytes <= ThrottleBytes) + PassTime(); + // Note, this is called IN LOCK + bool haskey = responses.ContainsKey(key); + if (!haskey) { - BytesSent += response.bytes; - //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; - //m_actions.Add(timeBasedAction); - return true; - } - // Big textures - else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes%50000) + 1)) - { - Interlocked.Increment(ref oversizedImages); - BytesSent += response.bytes; - //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; - //m_actions.Add(timeBasedAction); - return true; + return false; } - else + GetTextureModule.aPollResponse response; + if (responses.TryGetValue(key, out response)) { - return false; + + // Normal + if (BytesSent + response.bytes <= ThrottleBytes) + { + BytesSent += response.bytes; + //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; + //m_actions.Add(timeBasedAction); + return true; + } + // Big textures + else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes % 50000) + 1)) + { + Interlocked.Increment(ref oversizedImages); + BytesSent += response.bytes; + //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; + //m_actions.Add(timeBasedAction); + return true; + } + else + { + return false; + } } + + return haskey; + } + public void ProcessTime() + { + PassTime(); } - return haskey; - } - public void ProcessTime() - { - PassTime(); - } - - - private void PassTime() - { - currenttime = Util.EnvironmentTickCount(); - int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); - //processTimeBasedActions(responses); - if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) + + private void PassTime() { - lastTimeElapsed = Util.EnvironmentTickCount(); - BytesSent -= ThrottleBytes; - if (BytesSent < 0) BytesSent = 0; - if (BytesSent < ThrottleBytes) + currenttime = Util.EnvironmentTickCount(); + int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); + //processTimeBasedActions(responses); + if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) { - oversizedImages = 0; + lastTimeElapsed = Util.EnvironmentTickCount(); + BytesSent -= ThrottleBytes; + if (BytesSent < 0) BytesSent = 0; + if (BytesSent < ThrottleBytes) + { + oversizedImages = 0; + } } } + public int ThrottleBytes; } - public int ThrottleBytes; } + + } -- cgit v1.1 From e9153e1d1aae50024d8cd05fe14a9bce34343a0e Mon Sep 17 00:00:00 2001 From: teravus Date: Thu, 15 Nov 2012 10:05:16 -0500 Subject: Revert "Merge master into teravuswork", it should have been avination, not master. This reverts commit dfac269032300872c4d0dc507f4f9062d102b0f4, reversing changes made to 619c39e5144f15aca129d6d999bcc5c34133ee64. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 9 ++++----- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 21 +++++++++++++++------ .../Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 2 +- .../ClientStack/Linden/Caps/RegionConsoleModule.cs | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index f6146a9..650cd50 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -241,8 +241,8 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler( "SEED", new RestStreamHandler("POST", capsBase + m_requestPath, SeedCapRequest, "SEED", null)); -// m_log.DebugFormat( -// "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_HostCapsObj.AgentID); + m_log.DebugFormat( + "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_HostCapsObj.AgentID); //m_capsHandlers["MapLayer"] = // new LLSDStreamhandler("POST", @@ -337,12 +337,11 @@ namespace OpenSim.Region.ClientStack.Linden public string SeedCapRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - m_log.DebugFormat( - "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID); +// m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint)) { - m_log.WarnFormat( + m_log.DebugFormat( "[CAPS]: Unauthorized CAPS client {0} from {1}", m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 5bbdce8..e113c60 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden //scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack); -// scene.EventManager.OnNewClient += OnNewClient; + scene.EventManager.OnNewClient += OnNewClient; // TODO: Leaving these open, or closing them when we // become a child is incorrect. It messes up TP in a big @@ -102,7 +102,6 @@ namespace OpenSim.Region.ClientStack.Linden // circuit is there. scene.EventManager.OnClientClosed += ClientClosed; - scene.EventManager.OnMakeChildAgent += MakeChildAgent; scene.EventManager.OnRegisterCaps += OnRegisterCaps; @@ -111,10 +110,10 @@ namespace OpenSim.Region.ClientStack.Linden false, "debug eq", "debug eq [0|1|2]", - "Turn on event queue debugging\n" - + " <= 0 - turns off all event queue logging\n" - + " >= 1 - turns on outgoing event logging\n" - + " >= 2 - turns on poll notification", + "Turn on event queue debugging" + + "<= 0 - turns off all event queue logging" + + ">= 1 - turns on outgoing event logging" + + ">= 2 - turns on poll notification", HandleDebugEq); } else @@ -227,6 +226,16 @@ namespace OpenSim.Region.ClientStack.Linden #endregion + private void OnNewClient(IClientAPI client) + { + //client.OnLogout += ClientClosed; + } + +// private void ClientClosed(IClientAPI client) +// { +// ClientClosed(client.AgentId); +// } + private void ClientClosed(UUID agentID, Scene scene) { // m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index d604cf6..cd70410 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests UUID spId = TestHelpers.ParseTail(0x1); SceneHelpers.AddScenePresence(m_scene, spId); - m_scene.IncomingCloseAgent(spId, false); + m_scene.IncomingCloseAgent(spId); // TODO: Add more assertions for the other aspects of event queues Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs index fcac182..0a5ad0f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.ClientStack.Linden UUID capID = UUID.Random(); -// m_log.DebugFormat("[REGION CONSOLE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); + m_log.DebugFormat("[REGION CONSOLE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); caps.RegisterHandler( "SimConsoleAsync", new ConsoleHandler("/CAPS/" + capID + "/", "SimConsoleAsync", agentID, this, m_scene)); -- cgit v1.1 From 5e0294815f7e3ec83b7e568e1468948ac0ff7331 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 17 Nov 2012 03:47:09 -0500 Subject: * Plumbing and basic setting of the GetMesh Cap Throttler. * Last step is to flip the throttle distribution. --- .../ClientStack/Linden/Caps/GetMeshModule.cs | 90 +++++++++++++++++----- 1 file changed, 72 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 8deff81..96b48ad 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -60,6 +60,7 @@ namespace OpenSim.Region.ClientStack.Linden private IAssetService m_AssetService; private bool m_Enabled = true; private string m_URL; + struct aPollRequest { public PollServiceMeshEventArgs thepoll; @@ -71,6 +72,7 @@ namespace OpenSim.Region.ClientStack.Linden { public Hashtable response; public int bytes; + public int lod; } @@ -112,6 +114,7 @@ namespace OpenSim.Region.ClientStack.Linden // Cap doesn't exist if (m_URL != string.Empty) m_Enabled = true; + } public void AddRegion(Scene pScene) @@ -192,7 +195,7 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceMeshEventArgs args; if (m_pollservices.TryGetValue(user, out args)) { - args.UpdateThrottle(imagethrottle); + args.UpdateThrottle(imagethrottle, p); } } @@ -242,11 +245,12 @@ namespace OpenSim.Region.ClientStack.Linden new Dictionary(); private Scene m_scene; - private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000, 10000); + private MeshCapsDataThrottler m_throttler; public PollServiceMeshEventArgs(UUID pId, Scene scene) : base(null, null, null, null, pId, int.MaxValue) { m_scene = scene; + m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene); // x is request id, y is userid HasEvents = (x, y) => { @@ -268,6 +272,7 @@ namespace OpenSim.Region.ClientStack.Linden } finally { + m_throttler.ProcessTime(); responses.Remove(x); } } @@ -323,7 +328,7 @@ namespace OpenSim.Region.ClientStack.Linden response["reusecontext"] = false; lock (responses) - responses[requestID] = new aPollResponse() { bytes = 0, response = response }; + responses[requestID] = new aPollResponse() { bytes = 0, response = response, lod = 0 }; return; } @@ -334,6 +339,7 @@ namespace OpenSim.Region.ClientStack.Linden responses[requestID] = new aPollResponse() { bytes = (int)response["int_bytes"], + lod = (int)response["int_lod"], response = response }; @@ -341,9 +347,9 @@ namespace OpenSim.Region.ClientStack.Linden m_throttler.ProcessTime(); } - internal void UpdateThrottle(int pimagethrottle) + internal void UpdateThrottle(int pimagethrottle, ScenePresence p) { - m_throttler.ThrottleBytes = pimagethrottle; + m_throttler.UpdateThrottle(pimagethrottle, p); } } @@ -398,18 +404,31 @@ namespace OpenSim.Region.ClientStack.Linden } } - internal sealed class CapsDataThrottler + internal sealed class MeshCapsDataThrottler { private volatile int currenttime = 0; private volatile int lastTimeElapsed = 0; private volatile int BytesSent = 0; - private int oversizedImages = 0; - public CapsDataThrottler(int pBytes, int max, int min) + private int Lod3 = 0; + private int Lod2 = 0; + private int Lod1 = 0; + private int UserSetThrottle = 0; + private int UDPSetThrottle = 0; + private int CapSetThrottle = 0; + private float CapThrottleDistributon = 0.30f; + private readonly Scene m_scene; + private ThrottleOutPacketType Throttle; + + public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene) { ThrottleBytes = pBytes; lastTimeElapsed = Util.EnvironmentTickCount(); + Throttle = ThrottleOutPacketType.Task; + m_scene = pScene; } + + public bool hasEvents(UUID key, Dictionary responses) { PassTime(); @@ -427,17 +446,23 @@ namespace OpenSim.Region.ClientStack.Linden if (BytesSent + response.bytes <= ThrottleBytes) { BytesSent += response.bytes; - //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + 1000, unlockyn = false }; - //m_actions.Add(timeBasedAction); + + return true; + } + // Lod3 Over + else if (response.bytes > ThrottleBytes && Lod3 <= (((ThrottleBytes * .30f) % 50000) + 1)) + { + Interlocked.Increment(ref Lod3); + BytesSent += response.bytes; + return true; } - // Big textures - else if (response.bytes > ThrottleBytes && oversizedImages <= ((ThrottleBytes % 50000) + 1)) + // Lod2 Over + else if (response.bytes > ThrottleBytes && Lod2 <= (((ThrottleBytes * .30f) % 10000) + 1)) { - Interlocked.Increment(ref oversizedImages); + Interlocked.Increment(ref Lod2); BytesSent += response.bytes; - //TimeBasedAction timeBasedAction = new TimeBasedAction { byteRemoval = response.bytes, requestId = key, timeMS = currenttime + (((response.bytes % ThrottleBytes)+1)*1000) , unlockyn = false }; - //m_actions.Add(timeBasedAction); + return true; } else @@ -448,6 +473,11 @@ namespace OpenSim.Region.ClientStack.Linden return haskey; } + public void SubtractBytes(int bytes,int lod) + { + BytesSent -= bytes; + } + public void ProcessTime() { PassTime(); @@ -459,18 +489,42 @@ namespace OpenSim.Region.ClientStack.Linden currenttime = Util.EnvironmentTickCount(); int timeElapsed = Util.EnvironmentTickCountSubtract(currenttime, lastTimeElapsed); //processTimeBasedActions(responses); - if (Util.EnvironmentTickCountSubtract(currenttime, timeElapsed) >= 1000) + if (currenttime - timeElapsed >= 1000) { lastTimeElapsed = Util.EnvironmentTickCount(); BytesSent -= ThrottleBytes; if (BytesSent < 0) BytesSent = 0; if (BytesSent < ThrottleBytes) { - oversizedImages = 0; + Lod3 = 0; + Lod2 = 0; + Lod1 = 0; } } } - public int ThrottleBytes; + private void AlterThrottle(int setting, ScenePresence p) + { + p.ControllingClient.SetAgentThrottleSilent((int)Throttle,setting); + } + + public int ThrottleBytes + { + get { return CapSetThrottle; } + set { CapSetThrottle = value; } + } + + internal void UpdateThrottle(int pimagethrottle, ScenePresence p) + { + // Client set throttle ! + UserSetThrottle = pimagethrottle; + CapSetThrottle = (int)(pimagethrottle*CapThrottleDistributon); + UDPSetThrottle = (int) (pimagethrottle*(100 - CapThrottleDistributon)); + if (CapSetThrottle < 4068) + CapSetThrottle = 4068; // at least two discovery mesh + p.ControllingClient.SetAgentThrottleSilent((int) Throttle, UDPSetThrottle); + ProcessTime(); + + } } } -- cgit v1.1 From 98b0cb8df8128d516c128cb78a58170e22a484b9 Mon Sep 17 00:00:00 2001 From: teravus Date: Thu, 22 Nov 2012 08:13:35 -0500 Subject: * While this is not producing any problems.. and does help in low bandwidth situations I can't demonstrate that it's better then just letting the client request what it needs in terms of responsiveness of the mesh in the scene yet. --- .../ClientStack/Linden/Caps/GetMeshModule.cs | 42 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 96b48ad..dd43328 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -250,7 +250,7 @@ namespace OpenSim.Region.ClientStack.Linden base(null, null, null, null, pId, int.MaxValue) { m_scene = scene; - m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene); + m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId); // x is request id, y is userid HasEvents = (x, y) => { @@ -419,21 +419,35 @@ namespace OpenSim.Region.ClientStack.Linden private float CapThrottleDistributon = 0.30f; private readonly Scene m_scene; private ThrottleOutPacketType Throttle; + private readonly UUID User; - public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene) + public MeshCapsDataThrottler(int pBytes, int max, int min, Scene pScene, UUID puser) { ThrottleBytes = pBytes; lastTimeElapsed = Util.EnvironmentTickCount(); Throttle = ThrottleOutPacketType.Task; m_scene = pScene; + User = puser; } public bool hasEvents(UUID key, Dictionary responses) { + const float ThirtyPercent = 0.30f; + const float FivePercent = 0.05f; PassTime(); // Note, this is called IN LOCK bool haskey = responses.ContainsKey(key); + + if (responses.Count > 2) + { + SplitThrottle(ThirtyPercent); + } + else + { + SplitThrottle(FivePercent); + } + if (!haskey) { return false; @@ -441,7 +455,8 @@ namespace OpenSim.Region.ClientStack.Linden aPollResponse response; if (responses.TryGetValue(key, out response)) { - + float LOD3Over = (((ThrottleBytes*CapThrottleDistributon)%50000) + 1); + float LOD2Over = (((ThrottleBytes*CapThrottleDistributon)%10000) + 1); // Normal if (BytesSent + response.bytes <= ThrottleBytes) { @@ -449,16 +464,16 @@ namespace OpenSim.Region.ClientStack.Linden return true; } - // Lod3 Over - else if (response.bytes > ThrottleBytes && Lod3 <= (((ThrottleBytes * .30f) % 50000) + 1)) + // Lod3 Over Throttle protection to keep things processing even when the throttle bandwidth is set too little. + else if (response.bytes > ThrottleBytes && Lod3 <= ((LOD3Over < 1)? 1: LOD3Over) ) { Interlocked.Increment(ref Lod3); BytesSent += response.bytes; return true; } - // Lod2 Over - else if (response.bytes > ThrottleBytes && Lod2 <= (((ThrottleBytes * .30f) % 10000) + 1)) + // Lod2 Over Throttle protection to keep things processing even when the throttle bandwidth is set too little. + else if (response.bytes > ThrottleBytes && Lod2 <= ((LOD2Over < 1) ? 1 : LOD2Over)) { Interlocked.Increment(ref Lod2); BytesSent += response.bytes; @@ -477,7 +492,20 @@ namespace OpenSim.Region.ClientStack.Linden { BytesSent -= bytes; } + private void SplitThrottle(float percentMultiplier) + { + if (CapThrottleDistributon != percentMultiplier) // don't switch it if it's already set at the % multipler + { + CapThrottleDistributon = percentMultiplier; + ScenePresence p; + if (m_scene.TryGetScenePresence(User, out p)) // If we don't get a user they're not here anymore. + { + AlterThrottle(UserSetThrottle, p); + } + } + } + public void ProcessTime() { PassTime(); -- cgit v1.1 From 7a093df24b470a6c80d67b1f8572f37a2a350521 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Dec 2012 03:35:55 +0100 Subject: Prevent a failed user relogi from throwing exceptions in poll services --- OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 2 +- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 6b33561..908f628 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -377,7 +377,7 @@ namespace OpenSim.Region.ClientStack.Linden protocol = "https"; } caps.RegisterHandler("GetMesh", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); - m_pollservices.Add(agentID, args); + m_pollservices[agentID] = args; m_capsDict[agentID] = capUrl; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index dd87671..d4dbfb9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -333,7 +333,7 @@ namespace OpenSim.Region.ClientStack.Linden protocol = "https"; } caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); - m_pollservices.Add(agentID, args); + m_pollservices[agentID] = args; m_capsDict[agentID] = capUrl; } -- cgit v1.1 From 6797ac14741851efa5ba60a00891e18cf7755c80 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 29 Dec 2012 08:53:58 -0500 Subject: * This finishes the implementation of AgentCachedTexture. Requires the XBakes Module and service for full functionality. Previous no-cache functionality works without the service and module. In some ways, I would have been happier not putting an AssetBase in WearableCacheItem.. but turns out it was probably unavoidable. No additional locks, yay. --- .../Linden/Caps/UploadBakedTextureModule.cs | 140 ++++++++++++++++++++- 1 file changed, 136 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 3b0ccd7..6778ba5 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs @@ -27,6 +27,7 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Collections.Specialized; using System.Drawing; using System.Drawing.Imaging; @@ -53,8 +54,8 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")] public class UploadBakedTextureModule : INonSharedRegionModule { -// private static readonly ILog m_log = -// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// For historical reasons this is fixed, but there @@ -64,31 +65,154 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_scene; private bool m_persistBakedTextures; + private IBakedTextureModule m_BakedTextureModule; + public void Initialise(IConfigSource source) { IConfig appearanceConfig = source.Configs["Appearance"]; if (appearanceConfig != null) m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); + + } public void AddRegion(Scene s) { m_scene = s; + } public void RemoveRegion(Scene s) { + s.EventManager.OnRegisterCaps -= RegisterCaps; + s.EventManager.OnNewPresence -= RegisterNewPresence; + s.EventManager.OnRemovePresence -= DeRegisterPresence; + m_BakedTextureModule = null; + m_scene = null; } + + public void RegionLoaded(Scene s) { m_scene.EventManager.OnRegisterCaps += RegisterCaps; + m_scene.EventManager.OnNewPresence += RegisterNewPresence; + m_scene.EventManager.OnRemovePresence += DeRegisterPresence; + + } + + private void DeRegisterPresence(UUID agentId) + { + ScenePresence presence = null; + if (m_scene.TryGetScenePresence(agentId, out presence)) + { + presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; + } + + } + + private void RegisterNewPresence(ScenePresence presence) + { + presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; + + } + + private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) + { + m_BakedTextureModule = m_scene.RequestModuleInterface(); + if (cacheItems.Length > 0) + { + m_log.Info("[Cacheitems]: " + cacheItems.Length); + for (int iter = 0; iter < cacheItems.Length; iter++) + { + m_log.Info("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + + cacheItems[iter].TextureID); + } + + ScenePresence p = null; + if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) + { + + WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; + if (existingitems == null) + { + if (m_BakedTextureModule != null) + { + WearableCacheItem[] savedcache = null; + try + { + if (p.Appearance.WearableCacheItemsDirty) + { + savedcache = m_BakedTextureModule.Get(p.UUID); + p.Appearance.WearableCacheItems = savedcache; + p.Appearance.WearableCacheItemsDirty = false; + } + + } + catch (InvalidOperationException) + { + } + + if (savedcache != null) + existingitems = savedcache; + } + } + // Existing items null means it's a fully new appearance + if (existingitems == null) + { + + for (int iter = 0; iter < cacheItems.Length; iter++) + { + + cacheItems[iter].TextureID = textureEntry.FaceTextures[cacheItems[iter].TextureIndex].TextureID; + if (m_scene.AssetService != null) + cacheItems[iter].TextureAsset = m_scene.AssetService.GetCached(cacheItems[iter].TextureID.ToString()); + + + } + } + else + + + { + // for each uploaded baked texture + for (int i = 0; i < cacheItems.Length; i++) + { + cacheItems[i].TextureID = + textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; + } + + for (int i = 0; i < cacheItems.Length; i++) + { + if (cacheItems[i].TextureAsset == null) + { + cacheItems[i].TextureAsset = m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); + } + } + } + + + + p.Appearance.WearableCacheItems = cacheItems; + + + + if (m_BakedTextureModule != null) + { + m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); + p.Appearance.WearableCacheItemsDirty = true; + + } + } + } } public void PostInitialise() { } + + public void Close() { } public string Name { get { return "UploadBakedTextureModule"; } } @@ -100,15 +224,23 @@ namespace OpenSim.Region.ClientStack.Linden public void RegisterCaps(UUID agentID, Caps caps) { + UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler( + caps, m_scene.AssetService, m_persistBakedTextures); + + + caps.RegisterHandler( "UploadBakedTexture", new RestStreamHandler( "POST", "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, - new UploadBakedTextureHandler( - caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture, + avatarhandler.UploadBakedTexture, "UploadBakedTexture", agentID.ToString())); + + + + } } } \ No newline at end of file -- cgit v1.1 From 2805ec64662494d680925c6034e59b823e051a9d Mon Sep 17 00:00:00 2001 From: teravus Date: Mon, 31 Dec 2012 23:04:28 -0500 Subject: * Fixed a bug that replayed old cached appearance when changing outfits * Added suser(bad client) DOS protection by limiting the max cacheitems to the maximum sane amount. * Prevents potential numerous loops from running amok and index errors if the client purposely provides bad cache info. * If the XBakes service wasn't running, the SetAvatarAppearance routine would crash when contacting the XBakes service even though it was in a Try/Catch for the appropriate error type. It only properly error handles with the type Exception :(. (commented on that because it's unusual) --- .../Linden/Caps/UploadBakedTextureModule.cs | 123 ++++++++++++++------- 1 file changed, 82 insertions(+), 41 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 6778ba5..6bed95f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs @@ -119,13 +119,20 @@ namespace OpenSim.Region.ClientStack.Linden private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) { + int maxCacheitemsLoop = cacheItems.Length; + if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES) + { + maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES; + m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES); + } + m_BakedTextureModule = m_scene.RequestModuleInterface(); if (cacheItems.Length > 0) { - m_log.Info("[Cacheitems]: " + cacheItems.Length); - for (int iter = 0; iter < cacheItems.Length; iter++) + m_log.Debug("[Cacheitems]: " + cacheItems.Length); + for (int iter = 0; iter < maxCacheitemsLoop; iter++) { - m_log.Info("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + + m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + cacheItems[iter].TextureID); } @@ -133,65 +140,99 @@ namespace OpenSim.Region.ClientStack.Linden if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) { - WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; - if (existingitems == null) + WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; + if (existingitems == null) + { + if (m_BakedTextureModule != null) { - if (m_BakedTextureModule != null) + WearableCacheItem[] savedcache = null; + try { - WearableCacheItem[] savedcache = null; - try - { - if (p.Appearance.WearableCacheItemsDirty) - { - savedcache = m_BakedTextureModule.Get(p.UUID); - p.Appearance.WearableCacheItems = savedcache; - p.Appearance.WearableCacheItemsDirty = false; - } - - } - catch (InvalidOperationException) + if (p.Appearance.WearableCacheItemsDirty) { + savedcache = m_BakedTextureModule.Get(p.UUID); + p.Appearance.WearableCacheItems = savedcache; + p.Appearance.WearableCacheItemsDirty = false; } - if (savedcache != null) - existingitems = savedcache; } + /* + * The following Catch types DO NOT WORK with m_BakedTextureModule.Get + * it jumps to the General Packet Exception Handler if you don't catch Exception! + * + catch (System.Net.Sockets.SocketException) + { + cacheItems = null; + } + catch (WebException) + { + cacheItems = null; + } + catch (InvalidOperationException) + { + cacheItems = null; + } */ + catch (Exception) + { + // The service logs a sufficient error message. + } + + + if (savedcache != null) + existingitems = savedcache; } - // Existing items null means it's a fully new appearance - if (existingitems == null) - { + } + // Existing items null means it's a fully new appearance + if (existingitems == null) + { - for (int iter = 0; iter < cacheItems.Length; iter++) + for (int i = 0; i < maxCacheitemsLoop; i++) + { + if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) { - - cacheItems[iter].TextureID = textureEntry.FaceTextures[cacheItems[iter].TextureIndex].TextureID; + cacheItems[i].TextureID = + textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; if (m_scene.AssetService != null) - cacheItems[iter].TextureAsset = m_scene.AssetService.GetCached(cacheItems[iter].TextureID.ToString()); - - + cacheItems[i].TextureAsset = + m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); + } + else + { + m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); } + + } - else - - + } + else + + + { + // for each uploaded baked texture + for (int i = 0; i < maxCacheitemsLoop; i++) { - // for each uploaded baked texture - for (int i = 0; i < cacheItems.Length; i++) + if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) { cacheItems[i].TextureID = textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; } - - for (int i = 0; i < cacheItems.Length; i++) + else { - if (cacheItems[i].TextureAsset == null) - { - cacheItems[i].TextureAsset = m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); - } + m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); } } - + for (int i = 0; i < maxCacheitemsLoop; i++) + { + if (cacheItems[i].TextureAsset == null) + { + cacheItems[i].TextureAsset = + m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); + } + } + } + + p.Appearance.WearableCacheItems = cacheItems; -- cgit v1.1 From 0a393b317dd6449e5a4ebbfc41dd3c8f4d9b2092 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 22:32:39 +0100 Subject: Add the new UpdateAgentInformation cap to make maturity on more recent viewers work. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index f6146a9..b06788b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -103,6 +103,7 @@ namespace OpenSim.Region.ClientStack.Linden private static readonly string m_getObjectPhysicsDataPath = "0101/"; private static readonly string m_getObjectCostPath = "0102/"; private static readonly string m_ResourceCostSelectedPath = "0103/"; + private static readonly string m_UpdateAgentInformationPath = "0500/"; // These are callbacks which will be setup by the scene so that we can update scene data when we @@ -287,6 +288,8 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); + IRequestHandler UpdateAgentInformationHandler = new RestStreamHandler("POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation); + m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler); m_HostCapsObj.RegisterHandler( "CopyInventoryFromNotecard", @@ -1438,6 +1441,22 @@ namespace OpenSim.Region.ClientStack.Linden string response = OSDParser.SerializeLLSDXmlString(resp); return response; } + + public string UpdateAgentInformation(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + + OSDMap accessPrefs = new OSDMap(); + accessPrefs["max"] = "A"; + + resp["access_prefs"] = accessPrefs; + + string response = OSDParser.SerializeLLSDXmlString(resp); + return response; + } } public class AssetUploader -- cgit v1.1 From b263587e2104f304f084c72fcb0cc1d155dacc1e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 13 Jan 2013 15:25:51 +0000 Subject: try to patch getmesh Throttle (test) --- OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 908f628..6ec1115 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -501,7 +501,8 @@ namespace OpenSim.Region.ClientStack.Linden ScenePresence p; if (m_scene.TryGetScenePresence(User, out p)) // If we don't get a user they're not here anymore. { - AlterThrottle(UserSetThrottle, p); +// AlterThrottle(UserSetThrottle, p); + UpdateThrottle(UserSetThrottle, p); } } } @@ -546,7 +547,12 @@ namespace OpenSim.Region.ClientStack.Linden // Client set throttle ! UserSetThrottle = pimagethrottle; CapSetThrottle = (int)(pimagethrottle*CapThrottleDistributon); - UDPSetThrottle = (int) (pimagethrottle*(100 - CapThrottleDistributon)); +// UDPSetThrottle = (int) (pimagethrottle*(100 - CapThrottleDistributon)); + + float udp = 1.0f - CapThrottleDistributon; + if(udp < 0.5f) + udp = 0.5f; + UDPSetThrottle = (int) ((float)pimagethrottle * udp); if (CapSetThrottle < 4068) CapSetThrottle = 4068; // at least two discovery mesh p.ControllingClient.SetAgentThrottleSilent((int) Throttle, UDPSetThrottle); -- cgit v1.1 From 9d1989e64fa460646f9a3d52d4024c3b56888617 Mon Sep 17 00:00:00 2001 From: teravus Date: Tue, 22 Jan 2013 18:49:50 -0500 Subject: * Handle a NRE with Baked Textures that may result in a failed appearance. This may be an issue, or it may be a symptom. --- .../Linden/Caps/UploadBakedTextureModule.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 6bed95f..eca576d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs @@ -190,8 +190,15 @@ namespace OpenSim.Region.ClientStack.Linden { if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) { - cacheItems[i].TextureID = - textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; + Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex]; + if (face == null) + { + textureEntry.CreateFace(cacheItems[i].TextureIndex); + textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID = + AppearanceManager.DEFAULT_AVATAR_TEXTURE; + continue; + } + cacheItems[i].TextureID =face.TextureID; if (m_scene.AssetService != null) cacheItems[i].TextureAsset = m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); @@ -213,8 +220,16 @@ namespace OpenSim.Region.ClientStack.Linden { if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) { + Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex]; + if (face == null) + { + textureEntry.CreateFace(cacheItems[i].TextureIndex); + textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID = + AppearanceManager.DEFAULT_AVATAR_TEXTURE; + continue; + } cacheItems[i].TextureID = - textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; + face.TextureID; } else { -- cgit v1.1 From 598f891d703593bde4b96472b5d1b1ce6aaf4c74 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 6 Feb 2013 04:03:32 +0100 Subject: Move SoubleQueu to Util. Change HTTP inv to prioritize COF. Determine COF for SP --- .../Linden/Caps/WebFetchInvDescModule.cs | 77 ++++++++++++++++++++-- 1 file changed, 70 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 04cd474..a823dd8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -39,10 +39,13 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Framework.Capabilities; using OpenSim.Services.Interfaces; using Caps = OpenSim.Framework.Capabilities.Caps; using OpenSim.Capabilities.Handlers; using OpenSim.Framework.Monitoring; +using OpenMetaverse; +using OpenMetaverse.StructuredData; namespace OpenSim.Region.ClientStack.Linden { @@ -52,11 +55,13 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")] public class WebFetchInvDescModule : INonSharedRegionModule { - struct aPollRequest + class aPollRequest { public PollServiceInventoryEventArgs thepoll; public UUID reqID; public Hashtable request; + public ScenePresence presence; + public List folders; } private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -71,8 +76,8 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_capsDict = new Dictionary(); private static Thread[] m_workerThreads = null; - private static OpenMetaverse.BlockingQueue m_queue = - new OpenMetaverse.BlockingQueue(); + private static DoubleQueue m_queue = + new DoubleQueue(); #region ISharedRegionModule Members @@ -143,12 +148,18 @@ namespace OpenSim.Region.ClientStack.Linden private class PollServiceInventoryEventArgs : PollServiceEventArgs { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary responses = new Dictionary(); - public PollServiceInventoryEventArgs(UUID pId) : + private Scene m_scene; + + public PollServiceInventoryEventArgs(Scene scene, UUID pId) : base(null, null, null, null, pId, int.MaxValue) { + m_scene = scene; + HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; GetEvents = (x, y) => { @@ -167,12 +178,64 @@ namespace OpenSim.Region.ClientStack.Linden Request = (x, y) => { + ScenePresence sp = m_scene.GetScenePresence(Id); + if (sp == null) + { + m_log.ErrorFormat("[INVENTORY]: Unable to find ScenePresence for {0}", Id); + return; + } + aPollRequest reqinfo = new aPollRequest(); reqinfo.thepoll = this; reqinfo.reqID = x; reqinfo.request = y; + reqinfo.presence = sp; + reqinfo.folders = new List(); + + // Decode the request here + string request = y["body"].ToString(); + + request = request.Replace("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); + + request = request.Replace("fetch_folders0", "fetch_folders0"); + request = request.Replace("fetch_folders1", "fetch_folders1"); + + Hashtable hash = new Hashtable(); + try + { + hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); + } + catch (LLSD.LLSDParseException e) + { + m_log.ErrorFormat("[INVENTORY]: Fetch error: {0}{1}" + e.Message, e.StackTrace); + m_log.Error("Request: " + request); + return; + } + + ArrayList foldersrequested = (ArrayList)hash["folders"]; + + bool highPriority = false; + + for (int i = 0; i < foldersrequested.Count; i++) + { + Hashtable inventoryhash = (Hashtable)foldersrequested[i]; + string folder = inventoryhash["folder_id"].ToString(); + UUID folderID; + if (UUID.TryParse(folder, out folderID)) + { + if (!reqinfo.folders.Contains(folderID)) + { + if (sp.COF != UUID.Zero && sp.COF == folderID) + highPriority = true; + reqinfo.folders.Add(folderID); + } + } + } - m_queue.Enqueue(reqinfo); + if (highPriority) + m_queue.EnqueueHigh(reqinfo); + else + m_queue.EnqueueLow(reqinfo); }; NoEvents = (x, y) => @@ -208,7 +271,7 @@ namespace OpenSim.Region.ClientStack.Linden response["reusecontext"] = false; response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( - requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); + requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); lock (responses) responses[requestID] = response; @@ -220,7 +283,7 @@ namespace OpenSim.Region.ClientStack.Linden string capUrl = "/CAPS/" + UUID.Random() + "/"; // Register this as a poll service - PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); + PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(m_scene, agentID); args.Type = PollServiceEventArgs.EventType.Inventory; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); -- cgit v1.1 From 6aa876a83b08390ab057eb012fd2c730010f79d8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Feb 2013 03:40:48 +0000 Subject: Rename Bounciness to Restitution --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 83347e2..d7d4708 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1316,7 +1316,7 @@ namespace OpenSim.Region.ClientStack.Linden object_data["PhysicsShapeType"] = obj.PhysicsShapeType; object_data["Density"] = obj.Density; object_data["Friction"] = obj.Friction; - object_data["Restitution"] = obj.Bounciness; + object_data["Restitution"] = obj.Restitution; object_data["GravityMultiplier"] = obj.GravityModifier; resp[uuid.ToString()] = object_data; -- cgit v1.1 From bbda7b94b3fe2350d5413879388cfce7309ca907 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Feb 2013 03:40:48 +0000 Subject: Rename Bounciness to Restitution --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index b06788b..2bb3d38 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1317,7 +1317,7 @@ namespace OpenSim.Region.ClientStack.Linden object_data["PhysicsShapeType"] = obj.PhysicsShapeType; object_data["Density"] = obj.Density; object_data["Friction"] = obj.Friction; - object_data["Restitution"] = obj.Bounciness; + object_data["Restitution"] = obj.Restitution; object_data["GravityMultiplier"] = obj.GravityModifier; resp[uuid.ToString()] = object_data; -- cgit v1.1 From 4c7df6a1473e4e0a144e06f6e318251419f64af8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 14 Feb 2013 07:17:27 +0100 Subject: Small fix to sim features module --- OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 191bccf..8f38737 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -94,6 +94,8 @@ namespace OpenSim.Region.ClientStack.Linden { m_scene = s; m_scene.EventManager.OnRegisterCaps += RegisterCaps; + + m_scene.RegisterModuleInterface(this); } public void RemoveRegion(Scene s) -- cgit v1.1 From 32c4e1a850fc271808f2e80c79c628ddc82e0206 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 14 Feb 2013 08:40:15 +0100 Subject: Add an event and some logic to allow customizing Simulator Features by avatar --- .../Linden/Caps/SimulatorFeaturesModule.cs | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 8f38737..6ef8815 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.Linden // private static readonly ILog m_log = // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; + private Scene m_scene; /// @@ -158,7 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden IRequestHandler reqHandler = new RestHTTPHandler( "GET", "/CAPS/" + UUID.Random(), - HandleSimulatorFeaturesRequest, "SimulatorFeatures", agentID.ToString()); + x => { return HandleSimulatorFeaturesRequest(x, agentID); }, "SimulatorFeatures", agentID.ToString()); caps.RegisterHandler("SimulatorFeatures", reqHandler); } @@ -187,18 +189,33 @@ namespace OpenSim.Region.ClientStack.Linden return new OSDMap(m_features); } - private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) + private OSDMap DeepCopy() + { + // This isn't the cheapest way of doing this but the rate + // of occurrence is low (on sim entry only) and it's a sure + // way to get a true deep copy. + OSD copy = OSDParser.DeserializeLLSDXml(OSDParser.SerializeLLSDXmlString(m_features)); + + return (OSDMap)copy; + } + + private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod, UUID agentID) { // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); + OSDMap copy = DeepCopy(); + + SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; + if (handlerOnSimulatorFeaturesRequest != null) + handlerOnSimulatorFeaturesRequest(agentID, ref copy); + //Send back data Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; - lock (m_features) - responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features); + responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(copy); return responsedata; } -- cgit v1.1 From 8c0b9080a4fb013d559966fc8c8175fb16162c2d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 18 Feb 2013 21:09:14 +0100 Subject: Fix an issue where the viewer would request the seed cap before there was a handler for it. --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 2bb3d38..248eab6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -343,6 +343,9 @@ namespace OpenSim.Region.ClientStack.Linden m_log.DebugFormat( "[CAPS]: Received SEED caps request in {0} for agent {1}", m_regionName, m_HostCapsObj.AgentID); + if (!m_HostCapsObj.WaitForActivation()) + return string.Empty; + if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint)) { m_log.WarnFormat( -- cgit v1.1 From e0e9118f8137ec95c73fe264f0c3fcf9f7305741 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 24 Feb 2013 18:31:49 +0100 Subject: The viewer tries to parse the error message body to LLSD - give it some. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 986a665..f6e501d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -467,8 +467,8 @@ namespace OpenSim.Region.ClientStack.Linden responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; responsedata["reusecontext"] = false; - responsedata["str_response_string"] = "Upstream error: "; - responsedata["error_status_text"] = "Upstream error:"; + responsedata["str_response_string"] = ""; + responsedata["error_status_text"] = ""; responsedata["http_protocol_version"] = "HTTP/1.0"; return responsedata; } -- cgit v1.1 From 2ad72db0ecd834ca7071aa6038f209b64f79b868 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 3 Mar 2013 11:40:46 +0100 Subject: Make a viewer sent XML error prettier --- OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index a823dd8..707cc93 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -211,6 +211,10 @@ namespace OpenSim.Region.ClientStack.Linden m_log.Error("Request: " + request); return; } + catch (System.Xml.XmlException) + { + m_log.ErrorFormat("[INVENTORY]: XML Format error"); + } ArrayList foldersrequested = (ArrayList)hash["folders"]; -- cgit v1.1 From c341664c1b8ccf3bd7b81795b900b971a15ff318 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 24 Mar 2013 18:56:28 +0100 Subject: Phase 1 of implementing a transfer permission. Overwrite libOMV's PermissionMask with our own and add export permissions as well as a new definition for "All" as meaning "all conventional permissions" rather than "all possible permissions" --- .../Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index eadca9b..921d3bf 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -50,6 +50,7 @@ using OpenSim.Services.Interfaces; using Caps = OpenSim.Framework.Capabilities.Caps; using OSDArray = OpenMetaverse.StructuredData.OSDArray; using OSDMap = OpenMetaverse.StructuredData.OSDMap; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Region.ClientStack.Linden { @@ -830,9 +831,9 @@ namespace OpenSim.Region.ClientStack.Linden texitem.Folder = texturesFolder; texitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export); - texitem.BasePermissions = (uint)PermissionMask.All; + texitem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; texitem.EveryOnePermissions = 0; texitem.NextPermissions = (uint)PermissionMask.All; texitem.CreationDate = Util.UnixTimeSinceEpoch(); @@ -1097,9 +1098,9 @@ namespace OpenSim.Region.ClientStack.Linden else { item.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export); - item.BasePermissions = (uint)PermissionMask.All; + item.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; item.EveryOnePermissions = 0; item.NextPermissions = (uint)PermissionMask.All; } -- cgit v1.1 From e39156c6569b10d48b0005b271f103387e16f527 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Apr 2013 01:38:21 +0200 Subject: Send 503 when throttling textures --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index d4dbfb9..a42c96c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -56,6 +56,7 @@ namespace OpenSim.Region.ClientStack.Linden public PollServiceTextureEventArgs thepoll; public UUID reqID; public Hashtable request; + public bool send503; } public class aPollResponse @@ -244,7 +245,19 @@ namespace OpenSim.Region.ClientStack.Linden reqinfo.thepoll = this; reqinfo.reqID = x; reqinfo.request = y; + reqinfo.send503 = false; + lock (responses) + { + if (responses.Count > 0) + { + if (m_queue.Count >= 4) + { + // Never allow more than 4 fetches to wait + reqinfo.send503 = true; + } + } + } m_queue.Enqueue(reqinfo); }; @@ -276,6 +289,22 @@ namespace OpenSim.Region.ClientStack.Linden UUID requestID = requestinfo.reqID; + if (requestinfo.send503) + { + response = new Hashtable(); + + response["int_response_code"] = 503; + response["str_response_string"] = "Throttled"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + lock (responses) + responses[requestID] = new aPollResponse() {bytes = 0, response = response}; + + return; + } + // If the avatar is gone, don't bother to get the texture if (m_scene.GetScenePresence(Id) == null) { @@ -385,6 +414,9 @@ namespace OpenSim.Region.ClientStack.Linden GetTextureModule.aPollResponse response; if (responses.TryGetValue(key, out response)) { + // This is any error response + if (response.bytes == 0) + return true; // Normal if (BytesSent + response.bytes <= ThrottleBytes) @@ -411,12 +443,12 @@ namespace OpenSim.Region.ClientStack.Linden return haskey; } + public void ProcessTime() { PassTime(); } - private void PassTime() { currenttime = Util.EnvironmentTickCount(); -- cgit v1.1 From 0af1d8fe196e403c066f7fc3dbc9f4b897b4da2c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 30 Apr 2013 23:35:59 +0200 Subject: Fix CAPS to work like they should - do not send caps to the viewer if they're not in the requested caps list. The previous wrong behavior caused the debug setting "UseHTTPInventory" to fail on all viewers when turned off. UDB inventory would not be correctly used in that case. --- .../ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 921d3bf..59b9585 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -355,11 +355,22 @@ namespace OpenSim.Region.ClientStack.Linden return string.Empty; } - Hashtable caps = m_HostCapsObj.CapsHandlers.GetCapsDetails(true); + OSDArray capsRequested = (OSDArray)OSDParser.DeserializeLLSDXml(request); + List validCaps = new List(); + + foreach (OSD c in capsRequested) + validCaps.Add(c.AsString()); + + Hashtable caps = m_HostCapsObj.CapsHandlers.GetCapsDetails(true, validCaps); // Add the external too foreach (KeyValuePair kvp in m_HostCapsObj.ExternalCapsHandlers) + { + if (!validCaps.Contains(kvp.Key)) + continue; + caps[kvp.Key] = kvp.Value; + } string result = LLSDHelpers.SerialiseLLSDReply(caps); -- cgit v1.1 From 4cb7ee47f209ffb0c8d8d04eba462c248c4740e0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 22 May 2013 23:49:34 +0200 Subject: Let the event queue do lees work - expire every 40s as per Teravus instead of every seconds - whoever put that in.... --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 37285e3..eb40eb1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -376,7 +376,7 @@ namespace OpenSim.Region.ClientStack.Linden // TODO: Add EventQueueGet name/description for diagnostics MainServer.Instance.AddPollServiceHTTPHandler( eventQueueGetPath, - new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 1000)); + new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 40000)); // m_log.DebugFormat( // "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", -- cgit v1.1 From 745a209bf2cf2465717f2d17fd5a506221c63ac5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 10 Jun 2013 01:16:22 +0200 Subject: Explicitly set uploaded mesh object perms --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 59b9585..8241e07 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -990,13 +990,20 @@ namespace OpenSim.Region.ClientStack.Linden else prim.Name = assetName + "#" + i.ToString(); + prim.EveryoneMask = 0; + prim.GroupMask = 0; + if (restrictPerms) { prim.BaseMask = (uint)(PermissionMask.Move | PermissionMask.Modify); - prim.EveryoneMask = 0; - prim.GroupMask = 0; - prim.NextOwnerMask = 0; prim.OwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify); + prim.NextOwnerMask = 0; + } + else + { + prim.BaseMask = (uint)PermissionMask.All | (uint)PermissionMask.Export; + prim.OwnerMask = (uint)PermissionMask.All | (uint)PermissionMask.Export; + prim.NextOwnerMask = (uint)PermissionMask.Transfer; } if(istest) @@ -1099,21 +1106,17 @@ namespace OpenSim.Region.ClientStack.Linden if (restrictPerms) { - item.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Modify); - item.BasePermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); + item.CurrentPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); item.EveryOnePermissions = 0; item.NextPermissions = 0; } else { - item.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export); - item.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; + item.CurrentPermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export; item.EveryOnePermissions = 0; - item.NextPermissions = (uint)PermissionMask.All; + item.NextPermissions = (uint)PermissionMask.Transfer; } item.CreationDate = Util.UnixTimeSinceEpoch(); -- cgit v1.1 From 823e8b5d19099fcc560cefeec5943b9a19571a37 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 7 Sep 2013 17:57:02 +0200 Subject: Add support for simple external CAPS texture services --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 50 ++++++++++++++-------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index a42c96c..0570144 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -77,6 +77,8 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_capsDict = new Dictionary(); private static Thread[] m_workerThreads = null; + private string m_Url = "localhost"; + private static OpenMetaverse.BlockingQueue m_queue = new OpenMetaverse.BlockingQueue(); @@ -86,6 +88,9 @@ namespace OpenSim.Region.ClientStack.Linden public void Initialise(IConfigSource source) { + IConfig config = source.Configs["ClientStack.LindenCaps"]; + if (config != null) + m_Url = config.GetString("Cap_GetTexture", "localhost"); } public void AddRegion(Scene s) @@ -343,27 +348,34 @@ namespace OpenSim.Region.ClientStack.Linden private void RegisterCaps(UUID agentID, Caps caps) { - string capUrl = "/CAPS/" + UUID.Random() + "/"; - - // Register this as a poll service - PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene); - - args.Type = PollServiceEventArgs.EventType.Texture; - MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); - - string hostName = m_scene.RegionInfo.ExternalHostName; - uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; - string protocol = "http"; - - if (MainServer.Instance.UseSSL) + if (m_Url == "localhost") + { + string capUrl = "/CAPS/" + UUID.Random() + "/"; + + // Register this as a poll service + PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene); + + args.Type = PollServiceEventArgs.EventType.Texture; + MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); + + string hostName = m_scene.RegionInfo.ExternalHostName; + uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; + string protocol = "http"; + + if (MainServer.Instance.UseSSL) + { + hostName = MainServer.Instance.SSLCommonName; + port = MainServer.Instance.SSLPort; + protocol = "https"; + } + caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); + m_pollservices[agentID] = args; + m_capsDict[agentID] = capUrl; + } + else { - hostName = MainServer.Instance.SSLCommonName; - port = MainServer.Instance.SSLPort; - protocol = "https"; + caps.RegisterHandler("GetTexture", m_Url); } - caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); - m_pollservices[agentID] = args; - m_capsDict[agentID] = capUrl; } private void DeregisterCaps(UUID agentID, Caps caps) -- cgit v1.1 From ee951f7a1038eee5f0760674b0cffab9a6d0328f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 24 Jul 2014 17:14:14 +0100 Subject: EventQueueGetModule: dont reuse queues, we dont know whats there; make pool silently loose requests for unknown avatars, or they will stay active until timeout after close ( possible not a big problem after not reusing queues ? ) --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index ffb53af..e0ce35b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -307,12 +307,12 @@ namespace OpenSim.Region.ClientStack.Linden lock (m_AvatarQueueUUIDMapping) { // Reuse open queues. The client does! - if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) - { +// if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) +// { //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); - eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; - } - else +// eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; +// } +// else { eventQueueGetUUID = UUID.Random(); //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); @@ -345,9 +345,6 @@ namespace OpenSim.Region.ClientStack.Linden public bool HasEvents(UUID requestID, UUID agentID) { - // Don't use this, because of race conditions at agent closing time - //Queue queue = TryGetQueue(agentID); - Queue queue = GetQueue(agentID); if (queue != null) lock (queue) @@ -356,7 +353,8 @@ namespace OpenSim.Region.ClientStack.Linden return queue.Count > 0; } - return false; + m_log.WarnFormat("POLLED FOR EVENTS BY {0} unknown agent", agentID); + return true; } /// @@ -382,7 +380,8 @@ namespace OpenSim.Region.ClientStack.Linden Queue queue = GetQueue(pAgentId); if (queue == null) { - return NoEvents(requestID, pAgentId); + //return NoEvents(requestID, pAgentId); + return null; } OSD element; -- cgit v1.1 From 86a9710e77b76fb8a37faf9dacd22a0973628d92 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 24 Jul 2014 23:32:39 +0100 Subject: change previus code, send a NoEvents response back to http server, even if we know there is no one there, so that the server finishes handling it. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index e0ce35b..4a2ac86 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -380,8 +380,7 @@ namespace OpenSim.Region.ClientStack.Linden Queue queue = GetQueue(pAgentId); if (queue == null) { - //return NoEvents(requestID, pAgentId); - return null; + return NoEvents(requestID, pAgentId); } OSD element; -- cgit v1.1 From fa59cddc28c107e47f8549b3944fa5f14f561926 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 25 Jul 2014 13:03:40 +0100 Subject: remove old and dead code that its only making it hard to understand --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 305 ++------------------- 1 file changed, 18 insertions(+), 287 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 4a2ac86..ddae267 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -77,7 +77,6 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_ids = new Dictionary(); private Dictionary> queues = new Dictionary>(); - private Dictionary m_QueueUUIDAvatarMapping = new Dictionary(); private Dictionary m_AvatarQueueUUIDMapping = new Dictionary(); #region INonSharedRegionModule methods @@ -254,28 +253,13 @@ namespace OpenSim.Region.ClientStack.Linden lock (queues) queues.Remove(agentID); - List removeitems = new List(); lock (m_AvatarQueueUUIDMapping) m_AvatarQueueUUIDMapping.Remove(agentID); - UUID searchval = UUID.Zero; - - removeitems.Clear(); - - lock (m_QueueUUIDAvatarMapping) + lock (m_ids) { - foreach (UUID ky in m_QueueUUIDAvatarMapping.Keys) - { - searchval = m_QueueUUIDAvatarMapping[ky]; - - if (searchval == agentID) - { - removeitems.Add(ky); - } - } - - foreach (UUID ky in removeitems) - m_QueueUUIDAvatarMapping.Remove(ky); + if (!m_ids.ContainsKey(agentID)) + m_ids.Remove(agentID); } // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); @@ -307,28 +291,18 @@ namespace OpenSim.Region.ClientStack.Linden lock (m_AvatarQueueUUIDMapping) { // Reuse open queues. The client does! -// if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) -// { - //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); -// eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; -// } -// else + // Its reuse caps path not queues those are been reused already + if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) { - eventQueueGetUUID = UUID.Random(); - //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); + m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); + eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; } - } - - lock (m_QueueUUIDAvatarMapping) - { - if (!m_QueueUUIDAvatarMapping.ContainsKey(eventQueueGetUUID)) - m_QueueUUIDAvatarMapping.Add(eventQueueGetUUID, agentID); - } - - lock (m_AvatarQueueUUIDMapping) - { - if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID)) + else + { + eventQueueGetUUID = UUID.Random(); m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); + m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); + } } caps.RegisterPollHandler( @@ -336,10 +310,14 @@ namespace OpenSim.Region.ClientStack.Linden new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); Random rnd = new Random(Environment.TickCount); + int nrnd = rnd.Next(30000000); + lock (m_ids) { if (!m_ids.ContainsKey(agentID)) - m_ids.Add(agentID, rnd.Next(30000000)); + m_ids.Add(agentID, nrnd); + else + m_ids[agentID] = nrnd; } } @@ -455,254 +433,7 @@ namespace OpenSim.Region.ClientStack.Linden return responsedata; } -// public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps) -// { -// // TODO: this has to be redone to not busy-wait (and block the thread), -// // TODO: as soon as we have a non-blocking way to handle HTTP-requests. -// -//// if (m_log.IsDebugEnabled) -//// { -//// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ "; -//// foreach (object key in request.Keys) -//// { -//// debug += key.ToString() + "=" + request[key].ToString() + " "; -//// } -//// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name); -//// } -// -// Queue queue = TryGetQueue(agentID); -// OSD element; -// -// lock (queue) -// element = queue.Dequeue(); // 15s timeout -// -// Hashtable responsedata = new Hashtable(); -// -// int thisID = 0; -// lock (m_ids) -// thisID = m_ids[agentID]; -// -// if (element == null) -// { -// //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName); -// if (thisID == -1) // close-request -// { -// m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName); -// responsedata["int_response_code"] = 404; //501; //410; //404; -// responsedata["content_type"] = "text/plain"; -// responsedata["keepalive"] = false; -// responsedata["str_response_string"] = "Closed EQG"; -// return responsedata; -// } -// responsedata["int_response_code"] = 502; -// responsedata["content_type"] = "text/plain"; -// responsedata["keepalive"] = false; -// responsedata["str_response_string"] = "Upstream error: "; -// responsedata["error_status_text"] = "Upstream error:"; -// responsedata["http_protocol_version"] = "HTTP/1.0"; -// return responsedata; -// } -// -// OSDArray array = new OSDArray(); -// if (element == null) // didn't have an event in 15s -// { -// // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! -// array.Add(EventQueueHelper.KeepAliveEvent()); -// //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); -// } -// else -// { -// array.Add(element); -// -// if (element is OSDMap) -// { -// OSDMap ev = (OSDMap)element; -// m_log.DebugFormat( -// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", -// ev["message"], m_scene.GetScenePresence(agentID).Name); -// } -// -// lock (queue) -// { -// while (queue.Count > 0) -// { -// element = queue.Dequeue(); -// -// if (element is OSDMap) -// { -// OSDMap ev = (OSDMap)element; -// m_log.DebugFormat( -// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", -// ev["message"], m_scene.GetScenePresence(agentID).Name); -// } -// -// array.Add(element); -// thisID++; -// } -// } -// } -// -// OSDMap events = new OSDMap(); -// events.Add("events", array); -// -// events.Add("id", new OSDInteger(thisID)); -// lock (m_ids) -// { -// m_ids[agentID] = thisID + 1; -// } -// -// responsedata["int_response_code"] = 200; -// responsedata["content_type"] = "application/xml"; -// responsedata["keepalive"] = false; -// responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); -// -// m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); -// -// return responsedata; -// } - -// public Hashtable EventQueuePath2(Hashtable request) -// { -// string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); -// // pull off the last "/" in the path. -// Hashtable responsedata = new Hashtable(); -// capuuid = capuuid.Substring(0, capuuid.Length - 1); -// capuuid = capuuid.Replace("/CAPS/EQG/", ""); -// UUID AvatarID = UUID.Zero; -// UUID capUUID = UUID.Zero; -// -// // parse the path and search for the avatar with it registered -// if (UUID.TryParse(capuuid, out capUUID)) -// { -// lock (m_QueueUUIDAvatarMapping) -// { -// if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) -// { -// AvatarID = m_QueueUUIDAvatarMapping[capUUID]; -// } -// } -// -// if (AvatarID != UUID.Zero) -// { -// return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); -// } -// else -// { -// responsedata["int_response_code"] = 404; -// responsedata["content_type"] = "text/plain"; -// responsedata["keepalive"] = false; -// responsedata["str_response_string"] = "Not Found"; -// responsedata["error_status_text"] = "Not Found"; -// responsedata["http_protocol_version"] = "HTTP/1.0"; -// return responsedata; -// // return 404 -// } -// } -// else -// { -// responsedata["int_response_code"] = 404; -// responsedata["content_type"] = "text/plain"; -// responsedata["keepalive"] = false; -// responsedata["str_response_string"] = "Not Found"; -// responsedata["error_status_text"] = "Not Found"; -// responsedata["http_protocol_version"] = "HTTP/1.0"; -// return responsedata; -// // return 404 -// } -// } - - public OSD EventQueueFallBack(string path, OSD request, string endpoint) - { - // This is a fallback element to keep the client from loosing EventQueueGet - // Why does CAPS fail sometimes!? - m_log.Warn("[EVENTQUEUE]: In the Fallback handler! We lost the Queue in the rest handler!"); - string capuuid = path.Replace("/CAPS/EQG/",""); - capuuid = capuuid.Substring(0, capuuid.Length - 1); - -// UUID AvatarID = UUID.Zero; - UUID capUUID = UUID.Zero; - if (UUID.TryParse(capuuid, out capUUID)) - { -/* Don't remove this yet code cleaners! - * Still testing this! - * - lock (m_QueueUUIDAvatarMapping) - { - if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) - { - AvatarID = m_QueueUUIDAvatarMapping[capUUID]; - } - } - - - if (AvatarID != UUID.Zero) - { - // Repair the CAP! - //OpenSim.Framework.Capabilities.Caps caps = m_scene.GetCapsHandlerForUser(AvatarID); - //string capsBase = "/CAPS/EQG/"; - //caps.RegisterHandler("EventQueueGet", - //new RestHTTPHandler("POST", capsBase + capUUID.ToString() + "/", - //delegate(Hashtable m_dhttpMethod) - //{ - // return ProcessQueue(m_dhttpMethod, AvatarID, caps); - //})); - // start new ID sequence. - Random rnd = new Random(System.Environment.TickCount); - lock (m_ids) - { - if (!m_ids.ContainsKey(AvatarID)) - m_ids.Add(AvatarID, rnd.Next(30000000)); - } - - - int thisID = 0; - lock (m_ids) - thisID = m_ids[AvatarID]; - - BlockingLLSDQueue queue = GetQueue(AvatarID); - OSDArray array = new OSDArray(); - LLSD element = queue.Dequeue(15000); // 15s timeout - if (element == null) - { - - array.Add(EventQueueHelper.KeepAliveEvent()); - } - else - { - array.Add(element); - while (queue.Count() > 0) - { - array.Add(queue.Dequeue(1)); - thisID++; - } - } - OSDMap events = new OSDMap(); - events.Add("events", array); - - events.Add("id", new LLSDInteger(thisID)); - - lock (m_ids) - { - m_ids[AvatarID] = thisID + 1; - } - - return events; - } - else - { - return new LLSD(); - } -* -*/ - } - else - { - //return new LLSD(); - } - - return new OSDString("shutdown404!"); - } - + public void DisableSimulator(ulong handle, UUID avatarID) { OSD item = EventQueueHelper.DisableSimulator(handle); -- cgit v1.1 From 70890e211a495c2120c801ac68b21fc3dbf51cbf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 25 Jul 2014 17:29:41 +0100 Subject: add queue transition code needs review/more testing --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 194 ++++++++++++--------- 1 file changed, 115 insertions(+), 79 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index ddae267..b0d30b6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -176,27 +176,6 @@ namespace OpenSim.Region.ClientStack.Linden } /// - /// Always returns a valid queue - /// - /// - /// - private Queue TryGetQueue(UUID agentId) - { - lock (queues) - { - if (!queues.ContainsKey(agentId)) - { - m_log.DebugFormat( - "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", - agentId, m_scene.RegionInfo.RegionName); - queues[agentId] = new Queue(); - } - - return queues[agentId]; - } - } - - /// /// May return a null queue /// /// @@ -278,47 +257,95 @@ namespace OpenSim.Region.ClientStack.Linden public void OnRegisterCaps(UUID agentID, Caps caps) { // Register an event queue for the client - m_log.DebugFormat( "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", agentID, caps, m_scene.RegionInfo.RegionName); - // Let's instantiate a Queue for this agent right now - TryGetQueue(agentID); - UUID eventQueueGetUUID; + Queue queue; + Random rnd = new Random(Environment.TickCount); + int nrnd = rnd.Next(30000000); + if (nrnd < 0) + nrnd = -nrnd; - lock (m_AvatarQueueUUIDMapping) + lock (queues) { - // Reuse open queues. The client does! - // Its reuse caps path not queues those are been reused already - if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) + if (queues.ContainsKey(agentID)) + queue = queues[agentID]; + else + queue = null; + + if (queue == null) { - m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); - eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; + queue = new Queue(); + queues[agentID] = queue; + + // push markers to handle old responses still waiting + // this will cost at most viewer getting two forced noevents + // even being a new queue better be safe + queue.Enqueue(null); + queue.Enqueue(null); // one should be enough + + lock (m_AvatarQueueUUIDMapping) + { + eventQueueGetUUID = UUID.Random(); + if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) + { + // oops this should not happen ? + m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID without a queue"); + eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; + } + m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); + } + lock (m_ids) + { + if (!m_ids.ContainsKey(agentID)) + m_ids.Add(agentID, nrnd); + else + m_ids[agentID] = nrnd; + } } else { - eventQueueGetUUID = UUID.Random(); - m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); - m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); + // push markers to handle old responses still waiting + // this will cost at most viewer getting two forced noevents + // even being a new queue better be safe + queue.Enqueue(null); + queue.Enqueue(null); // one should be enough + + // reuse or not to reuse TODO FIX + lock (m_AvatarQueueUUIDMapping) + { + // Reuse open queues. The client does! + // Its reuse caps path not queues those are been reused already + if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) + { + m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); + eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; + } + else + { + eventQueueGetUUID = UUID.Random(); + m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); + m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); + } + } + lock (m_ids) + { + // change to negative numbers so they are changed at end of sending first marker + // old data on a queue may be sent on a response for a new caps + // but at least will be sent with coerent IDs + if (!m_ids.ContainsKey(agentID)) + m_ids.Add(agentID, -nrnd); // should not happen + else + m_ids[agentID] = -m_ids[agentID]; + } } } caps.RegisterPollHandler( "EventQueueGet", new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); - - Random rnd = new Random(Environment.TickCount); - int nrnd = rnd.Next(30000000); - - lock (m_ids) - { - if (!m_ids.ContainsKey(agentID)) - m_ids.Add(agentID, nrnd); - else - m_ids[agentID] = nrnd; - } } public bool HasEvents(UUID requestID, UUID agentID) @@ -361,55 +388,65 @@ namespace OpenSim.Region.ClientStack.Linden return NoEvents(requestID, pAgentId); } - OSD element; + OSD element = null;; + OSDArray array = new OSDArray(); + int thisID = 0; + bool negativeID = false; + lock (queue) { if (queue.Count == 0) return NoEvents(requestID, pAgentId); - element = queue.Dequeue(); // 15s timeout - } - - int thisID = 0; - lock (m_ids) - thisID = m_ids[pAgentId]; - - OSDArray array = new OSDArray(); - if (element == null) // didn't have an event in 15s - { - // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! - array.Add(EventQueueHelper.KeepAliveEvent()); - //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName); - } - else - { - if (DebugLevel > 0) - LogOutboundDebugMessage(element, pAgentId); - array.Add(element); + lock (m_ids) + thisID = m_ids[pAgentId]; - lock (queue) + if (thisID < 0) { - while (queue.Count > 0) - { - element = queue.Dequeue(); + negativeID = true; + thisID = -thisID; + } + + while (queue.Count > 0) + { + element = queue.Dequeue(); + // add elements until a marker is found + // so they get into a response + if (element == null) + break; + if (DebugLevel > 0) + LogOutboundDebugMessage(element, pAgentId); + array.Add(element); + thisID++; + } + } - if (DebugLevel > 0) - LogOutboundDebugMessage(element, pAgentId); + OSDMap events = null; - array.Add(element); - thisID++; - } - } + if (array.Count > 0) + { + events = new OSDMap(); + events.Add("events", array); + events.Add("id", new OSDInteger(thisID)); } - OSDMap events = new OSDMap(); - events.Add("events", array); + if (negativeID && element == null) + { + Random rnd = new Random(Environment.TickCount); + thisID = rnd.Next(30000000); + if (thisID < 0) + thisID = -thisID; + } - events.Add("id", new OSDInteger(thisID)); lock (m_ids) { m_ids[pAgentId] = thisID + 1; } + + // if there where no elements before a marker send a NoEvents + if (array.Count == 0) + return NoEvents(requestID, pAgentId); + Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "application/xml"; @@ -432,7 +469,6 @@ namespace OpenSim.Region.ClientStack.Linden responsedata["http_protocol_version"] = "HTTP/1.0"; return responsedata; } - public void DisableSimulator(ulong handle, UUID avatarID) { -- cgit v1.1 From 9f5e19127d79a8790c31e80a4c6ae8d04d79d6ac Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 3 Aug 2014 00:22:21 +0100 Subject: comment out a debug msg. more on gods being Gods --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index b0d30b6..ca6c3ca 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -358,7 +358,7 @@ namespace OpenSim.Region.ClientStack.Linden return queue.Count > 0; } - m_log.WarnFormat("POLLED FOR EVENTS BY {0} unknown agent", agentID); + //m_log.WarnFormat("POLLED FOR EVENTS BY {0} unknown agent", agentID); return true; } -- cgit v1.1 From 66dea8fe05dbf0f9783f520cddf4d3aa700015d6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 6 Aug 2014 05:17:30 +0100 Subject: some debug to remove later --- OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 47988dd..19afe97 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs @@ -268,6 +268,12 @@ namespace OpenSim.Region.ClientStack.Linden } } } + + for (int iter = 0; iter < maxCacheitemsLoop; iter++) + { + m_log.Debug("[CacheitemsLeaving] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + + cacheItems[iter].TextureID); + } } public void PostInitialise() -- cgit v1.1 From 552b4e45e8700cc71bbbea18b5bad167998a74e4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 6 Aug 2014 05:56:10 +0100 Subject: bakemodule didnt like last changes --- .../Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 19afe97..2da653d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs @@ -254,18 +254,16 @@ namespace OpenSim.Region.ClientStack.Linden } } - - p.Appearance.WearableCacheItems = cacheItems; - - - + if (m_BakedTextureModule != null) { m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); p.Appearance.WearableCacheItemsDirty = true; } + else + p.Appearance.WearableCacheItemsDirty = false; } } -- cgit v1.1 From c3f9c99fb32d15e57b24502b71c79fe028ed3007 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 7 Aug 2014 05:20:45 +0100 Subject: DANGER... changed bakedtextures caching. Assuming grid baking is cache only, reduced number of accesses to it. TESTING --- .../Linden/Caps/UploadBakedTextureModule.cs | 124 ++++++++++----------- 1 file changed, 56 insertions(+), 68 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 2da653d..50e9275 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs @@ -96,9 +96,7 @@ namespace OpenSim.Region.ClientStack.Linden s.EventManager.OnRemovePresence -= DeRegisterPresence; m_BakedTextureModule = null; m_scene = null; - } - - + } public void RegionLoaded(Scene s) { @@ -110,44 +108,58 @@ namespace OpenSim.Region.ClientStack.Linden private void DeRegisterPresence(UUID agentId) { - ScenePresence presence = null; - if (m_scene.TryGetScenePresence(agentId, out presence)) +// ScenePresence presence = null; +// if (m_scene.TryGetScenePresence(agentId, out presence)) { - presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; +// presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; } } private void RegisterNewPresence(ScenePresence presence) { - presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; - +// presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; } - private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) - { - int maxCacheitemsLoop = cacheItems.Length; - if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES) - { - maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES; - m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES); - } - - m_BakedTextureModule = m_scene.RequestModuleInterface(); - if (cacheItems.Length > 0) - { - m_log.Debug("[Cacheitems]: " + cacheItems.Length); - for (int iter = 0; iter < maxCacheitemsLoop; iter++) - { - m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + - cacheItems[iter].TextureID); - } - - ScenePresence p = null; - if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) +/* not in use. work done in AvatarFactoryModule ValidateBakedTextureCache() and UpdateBakedTextureCache() + private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) { + // if cacheItems.Length > 0 viewer is giving us current textures information. + // baked ones should had been uploaded and in assets cache as local itens + + + if (cacheItems.Length == 0) + return; // no textures information, nothing to do + + ScenePresence p = null; + if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) + return; // what are we doing if there is no presence to cache for? + + if (p.IsDeleted) + return; // does this really work? + + int maxCacheitemsLoop = cacheItems.Length; + if (maxCacheitemsLoop > 20) + { + maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES; + m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES); + } + + m_BakedTextureModule = m_scene.RequestModuleInterface(); + + + // some nice debug + m_log.Debug("[Cacheitems]: " + cacheItems.Length); + for (int iter = 0; iter < maxCacheitemsLoop; iter++) + { + m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + + cacheItems[iter].TextureID); + } + + // p.Appearance.WearableCacheItems is in memory primary cashID to textures mapper WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; + if (existingitems == null) { if (m_BakedTextureModule != null) @@ -161,38 +173,22 @@ namespace OpenSim.Region.ClientStack.Linden p.Appearance.WearableCacheItems = savedcache; p.Appearance.WearableCacheItemsDirty = false; } - } - /* - * The following Catch types DO NOT WORK with m_BakedTextureModule.Get - * it jumps to the General Packet Exception Handler if you don't catch Exception! - * - catch (System.Net.Sockets.SocketException) - { - cacheItems = null; - } - catch (WebException) - { - cacheItems = null; - } - catch (InvalidOperationException) - { - cacheItems = null; - } */ + catch (Exception) { - // The service logs a sufficient error message. + // The service logs a sufficient error message. } - + if (savedcache != null) existingitems = savedcache; } } + // Existing items null means it's a fully new appearance if (existingitems == null) { - for (int i = 0; i < maxCacheitemsLoop; i++) { if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) @@ -205,7 +201,7 @@ namespace OpenSim.Region.ClientStack.Linden AppearanceManager.DEFAULT_AVATAR_TEXTURE; continue; } - cacheItems[i].TextureID =face.TextureID; + cacheItems[i].TextureID = face.TextureID; if (m_scene.AssetService != null) cacheItems[i].TextureAsset = m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); @@ -214,15 +210,10 @@ namespace OpenSim.Region.ClientStack.Linden { m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); } - - } } else - - - { - // for each uploaded baked texture + { for (int i = 0; i < maxCacheitemsLoop; i++) { if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) @@ -253,27 +244,24 @@ namespace OpenSim.Region.ClientStack.Linden } } } - p.Appearance.WearableCacheItems = cacheItems; - + if (m_BakedTextureModule != null) { m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); p.Appearance.WearableCacheItemsDirty = true; - + } else p.Appearance.WearableCacheItemsDirty = false; - } - } - - for (int iter = 0; iter < maxCacheitemsLoop; iter++) - { - m_log.Debug("[CacheitemsLeaving] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + - cacheItems[iter].TextureID); - } - } + for (int iter = 0; iter < maxCacheitemsLoop; iter++) + { + m_log.Debug("[CacheitemsLeaving] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + + cacheItems[iter].TextureID); + } + } + */ public void PostInitialise() { } -- cgit v1.1 From 2eb1c1c37765a42fd24467f26cf53e7443d5a75b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 9 Aug 2014 15:15:27 +0100 Subject: move from RegisterInventoryServiceHandlers to RegisterRegionServiceHandlers what belongs there ( readabilitly only ) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 613bc24..3949f8b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -248,7 +248,19 @@ namespace OpenSim.Region.ClientStack.Linden //m_capsHandlers["MapLayer"] = // new LLSDStreamhandler("POST", // capsBase + m_mapLayerPath, - // GetMapLayer); + // GetMapLayer); + + IRequestHandler getObjectPhysicsDataHandler + = new RestStreamHandler( + "POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData, "GetObjectPhysicsData", null); + m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler); + + IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); + m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); + IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); + m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); + + IRequestHandler req = new RestStreamHandler( "POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory, "UpdateScript", null); @@ -283,14 +295,7 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); - IRequestHandler getObjectPhysicsDataHandler - = new RestStreamHandler( - "POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData, "GetObjectPhysicsData", null); - m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler); - IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); - m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); - IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); - m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); + IRequestHandler UpdateAgentInformationHandler = new RestStreamHandler( -- cgit v1.1 From 601c50dc1e2e590a227a7b641be68cbcde6c279d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 9 Aug 2014 16:19:07 +0100 Subject: return even zero costs ( prims on other regions ) --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 3949f8b..0141940 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1448,7 +1448,7 @@ namespace OpenSim.Region.ClientStack.Linden } } - if (simul != 0) + // if (simul != 0) { OSDMap object_data = new OSDMap(); -- cgit v1.1 From c84a3c3630fe678d618667ee472a0852f2921f64 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 9 Aug 2014 16:22:46 +0100 Subject: also on other case --- .../Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 0141940..61b9045 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1384,6 +1384,17 @@ namespace OpenSim.Region.ClientStack.Linden resp[uuid.ToString()] = object_data; } + else + { + OSDMap object_data = new OSDMap(); + object_data["linked_set_resource_cost"] = 0; + object_data["resource_cost"] = 0; + object_data["physics_cost"] = 0; + object_data["linked_set_physics_cost"] = 0; + + resp[uuid.ToString()] = object_data; + } + } } -- cgit v1.1 From 18de5c8a2da2577246485f8df100e1e155a30d56 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 29 Aug 2014 16:30:49 +0100 Subject: make use of it in GetMeshModule, and meshs are Assets not Task itens, reduce MeshModule impact on udp rate --- .../ClientStack/Linden/Caps/GetMeshModule.cs | 47 ++-------------------- 1 file changed, 4 insertions(+), 43 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 7b15284..a381a1b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -189,9 +189,8 @@ namespace OpenSim.Region.ClientStack.Linden // Now we know when the throttle is changed by the client in the case of a root agent or by a neighbor region in the case of a child agent. public void ThrottleUpdate(ScenePresence p) { - byte[] throttles = p.ControllingClient.GetThrottlesPacked(1); UUID user = p.UUID; - int imagethrottle = ExtractTaskThrottle(throttles); + int imagethrottle = p.ControllingClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Asset); PollServiceMeshEventArgs args; if (m_pollservices.TryGetValue(user, out args)) { @@ -199,44 +198,6 @@ namespace OpenSim.Region.ClientStack.Linden } } - private int ExtractTaskThrottle(byte[] pthrottles) - { - - byte[] adjData; - int pos = 0; - - if (!BitConverter.IsLittleEndian) - { - byte[] newData = new byte[7 * 4]; - Buffer.BlockCopy(pthrottles, 0, newData, 0, 7 * 4); - - for (int i = 0; i < 7; i++) - Array.Reverse(newData, i * 4, 4); - - adjData = newData; - } - else - { - adjData = pthrottles; - } - - // 0.125f converts from bits to bytes - //int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - //pos += 4; - // int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - //pos += 4; - // int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - // pos += 4; - // int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - // pos += 4; - pos += 16; - int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - // pos += 4; - //int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); //pos += 4; - //int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); - return task; - } - private class PollServiceMeshEventArgs : PollServiceEventArgs { private List requests = @@ -425,7 +386,7 @@ namespace OpenSim.Region.ClientStack.Linden { ThrottleBytes = pBytes; lastTimeElapsed = Util.EnvironmentTickCount(); - Throttle = ThrottleOutPacketType.Task; + Throttle = ThrottleOutPacketType.Asset; m_scene = pScene; User = puser; } @@ -550,8 +511,8 @@ namespace OpenSim.Region.ClientStack.Linden // UDPSetThrottle = (int) (pimagethrottle*(100 - CapThrottleDistributon)); float udp = 1.0f - CapThrottleDistributon; - if(udp < 0.5f) - udp = 0.5f; + if(udp < 0.7f) + udp = 0.7f; UDPSetThrottle = (int) ((float)pimagethrottle * udp); if (CapSetThrottle < 4068) CapSetThrottle = 4068; // at least two discovery mesh -- cgit v1.1 From 18cc33e2c55539596363a0233bc680034bfacef6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 25 Sep 2014 13:35:30 +0100 Subject: add animationset to upload assets, for now no cost --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 61b9045..593bd52 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -757,6 +757,12 @@ namespace OpenSim.Region.ClientStack.Linden inType = (sbyte)InventoryType.Animation; assType = (sbyte)AssetType.Animation; } + else if (inventoryType == "animationset") + { + inType = (sbyte)CustomInventoryType.AnimationSet; + assType = (sbyte)CustomAssetType.AnimationSet; + m_log.Debug("got animationset upload request"); + } else if (inventoryType == "wearable") { inType = (sbyte)InventoryType.Wearable; -- cgit v1.1 From f51779bb05b29558e3908ad9931ed61ddc61f390 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 25 Sep 2014 14:10:44 +0100 Subject: add also the name animset until its clear the name liru will use --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 593bd52..01d4248 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -757,12 +757,19 @@ namespace OpenSim.Region.ClientStack.Linden inType = (sbyte)InventoryType.Animation; assType = (sbyte)AssetType.Animation; } +// add add both animationset and animset until is clear what name Liru will use else if (inventoryType == "animationset") { inType = (sbyte)CustomInventoryType.AnimationSet; assType = (sbyte)CustomAssetType.AnimationSet; m_log.Debug("got animationset upload request"); } + else if (inventoryType == "animset") + { + inType = (sbyte)CustomInventoryType.AnimationSet; + assType = (sbyte)CustomAssetType.AnimationSet; + m_log.Debug("got animset upload request"); + } else if (inventoryType == "wearable") { inType = (sbyte)InventoryType.Wearable; -- cgit v1.1 From 57166878b54ca1495e244a2a1ef791129b42d70f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 25 Sep 2014 16:37:43 +0100 Subject: fix animation asset name to "animatn", use "animset" for the new animationSet --- .../ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 01d4248..9b12dd2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -530,6 +530,7 @@ namespace OpenSim.Region.ClientStack.Linden if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || + llsdRequest.asset_type == "animatn" || // this is the asset name actually used by viewers llsdRequest.asset_type == "mesh" || llsdRequest.asset_type == "sound") { @@ -757,13 +758,6 @@ namespace OpenSim.Region.ClientStack.Linden inType = (sbyte)InventoryType.Animation; assType = (sbyte)AssetType.Animation; } -// add add both animationset and animset until is clear what name Liru will use - else if (inventoryType == "animationset") - { - inType = (sbyte)CustomInventoryType.AnimationSet; - assType = (sbyte)CustomAssetType.AnimationSet; - m_log.Debug("got animationset upload request"); - } else if (inventoryType == "animset") { inType = (sbyte)CustomInventoryType.AnimationSet; @@ -1121,7 +1115,15 @@ namespace OpenSim.Region.ClientStack.Linden // If we set PermissionMask.All then when we rez the item the next permissions will replace the current // (owner) permissions. This becomes a problem if next permissions are changed. - if (restrictPerms) + if (inType == (sbyte)CustomInventoryType.AnimationSet) + { + item.BasePermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify); + item.CurrentPermissions = (uint)(PermissionMask.Copy| PermissionMask.Modify); + item.EveryOnePermissions = 0; + item.NextPermissions = 0; + } + + else if (restrictPerms) { item.BasePermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); item.CurrentPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); -- cgit v1.1 From 3a42ea52792438b44c6ddbd17eaad93c32263bbb Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 25 Sep 2014 21:21:20 +0200 Subject: Extend upload verification to all upload paths --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 9b12dd2..0e38d05 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -105,6 +105,7 @@ namespace OpenSim.Region.ClientStack.Linden private static readonly string m_getObjectCostPath = "0102/"; private static readonly string m_ResourceCostSelectedPath = "0103/"; private static readonly string m_UpdateAgentInformationPath = "0500/"; + private static readonly string m_animSetTaskUpdatePath = "0260/"; // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls @@ -267,6 +268,12 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptTask", req); + +// IRequestHandler animSetRequestHandler +// = new RestStreamHandler( +// "POST", capsBase + m_animSetTaskUpdatePath, AnimSetTaskInventory, "UpdateScript", null); + +// m_HostCapsObj.RegisterHandler("UpdateAnimSetTaskInventory", animSetRequestHandler); } catch (Exception e) { @@ -292,6 +299,7 @@ namespace OpenSim.Region.ClientStack.Linden "POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory, "Update*", null); m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); + m_HostCapsObj.RegisterHandler("UpdateAnimSetAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); -- cgit v1.1 From 5f57b55dc97eb943af4c0429a68f074b490fffd7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 26 Sep 2014 14:08:21 +0100 Subject: use central animationset permitions define --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 0e38d05..a32593a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1125,8 +1125,8 @@ namespace OpenSim.Region.ClientStack.Linden if (inType == (sbyte)CustomInventoryType.AnimationSet) { - item.BasePermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify); - item.CurrentPermissions = (uint)(PermissionMask.Copy| PermissionMask.Modify); + item.BasePermissions = AnimationSet.allowedPermitions; + item.CurrentPermissions = AnimationSet.allowedPermitions; item.EveryOnePermissions = 0; item.NextPermissions = 0; } -- cgit v1.1 From fcad64209c29c55cbec78ae94f221120e9956ebf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 26 Sep 2014 14:17:01 +0100 Subject: make c# more happy --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index a32593a..a31532b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1125,10 +1125,7 @@ namespace OpenSim.Region.ClientStack.Linden if (inType == (sbyte)CustomInventoryType.AnimationSet) { - item.BasePermissions = AnimationSet.allowedPermitions; - item.CurrentPermissions = AnimationSet.allowedPermitions; - item.EveryOnePermissions = 0; - item.NextPermissions = 0; + AnimationSet.enforceItemPermitions(ref item); } else if (restrictPerms) -- cgit v1.1 From 90cad824050ffbd081baf5338638e2e6d95903f2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 26 Sep 2014 14:22:54 +0100 Subject: remove unnecessary argument ref --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index a31532b..1e28db0 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1125,7 +1125,7 @@ namespace OpenSim.Region.ClientStack.Linden if (inType == (sbyte)CustomInventoryType.AnimationSet) { - AnimationSet.enforceItemPermitions(ref item); + AnimationSet.enforceItemPermitions(item); } else if (restrictPerms) -- cgit v1.1 From 46caea6987a24e07f61e3c3bef24ab4495899bda Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 26 Sep 2014 15:03:33 +0100 Subject: change it again... --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 1e28db0..75634e0 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1125,7 +1125,7 @@ namespace OpenSim.Region.ClientStack.Linden if (inType == (sbyte)CustomInventoryType.AnimationSet) { - AnimationSet.enforceItemPermitions(item); + AnimationSet.setCreateItemPermitions(item); } else if (restrictPerms) -- cgit v1.1 From 1a6ef2d60e4aff73e614ef45a0040c45316707f3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 11 Oct 2014 10:01:26 +0100 Subject: check for avatar skeleton data on meshs headers on cost estimation. Dont let a model have more than one mesh with skeleton, for testing create a mesh inventory item, for this meshs. Add also option to read a avatar collider replacement. This information still needs to be saved somewhere so it can be checked on attachment, etc, without parsing the mesh asset again. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 68 ++++++++++++++++++++-- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 44 ++++++++++++-- 2 files changed, 101 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 75634e0..3a070c3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.ClientStack.Linden string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload, ref string error); + bool IsAtestUpload, bool avatarSkeleton, bool avatarCollider, ref string error); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -531,6 +531,8 @@ namespace OpenSim.Region.ClientStack.Linden int nreqmeshs= 0; int nreqinstances = 0; bool IsAtestUpload = false; + bool avatarSkeleton = false; + bool avatarCollider = false; string assetName = llsdRequest.name; @@ -580,8 +582,9 @@ namespace OpenSim.Region.ClientStack.Linden string error; int modelcost; + if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, - meshcostdata, out error, ref warning)) + meshcostdata,out avatarSkeleton, out avatarCollider, out error, ref warning)) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = error; @@ -664,7 +667,7 @@ namespace OpenSim.Region.ClientStack.Linden AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, - texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload); + texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload, avatarSkeleton, avatarCollider); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -711,7 +714,7 @@ namespace OpenSim.Region.ClientStack.Linden UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload, ref string error) + bool IsAtestUpload,bool avatarSkeleton, bool avatarCollider, ref string error) { lock (m_ModelCost) @@ -877,12 +880,60 @@ namespace OpenSim.Region.ClientStack.Linden List meshAssets = new List(); for (int i = 0; i < mesh_list.Count; i++) { +/* + // do we really need this heavy thing? + OSD osd = OSDParser.DeserializeLLSDBinary(mesh_list[i]); + if (osd is OSDMap) + { + OSDMap mosd = (OSDMap)osd; + if (mosd.ContainsKey("skeleton")) + { + OSDMap skeleton = (OSDMap)mosd["skeleton"]; + int sksize = skeleton["size"].AsInteger(); + } + } +*/ + AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); meshAsset.Data = mesh_list[i].AsBinary(); if (istest) meshAsset.Local = true; m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); + + + // test code + if (avatarSkeleton) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Mesh#" + i.ToString(); + InventoryItemBase meshitem = new InventoryItemBase(); + meshitem.Owner = m_HostCapsObj.AgentID; + meshitem.CreatorId = creatorIDstr; + meshitem.CreatorData = String.Empty; + meshitem.ID = UUID.Random(); + meshitem.AssetID = meshAsset.FullID; + meshitem.Description = "mesh "; + meshitem.Name = name; + meshitem.AssetType = (int)AssetType.Mesh; + meshitem.InvType = (int)InventoryType.Mesh; + meshitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + meshitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + meshitem.BasePermissions = (uint)PermissionMask.All; + meshitem.EveryOnePermissions = 0; + meshitem.NextPermissions = (uint)PermissionMask.All; + meshitem.CreationDate = Util.UnixTimeSinceEpoch(); + + m_Scene.AddInventoryItem(client, meshitem); + meshitem = null; + } } int skipedMeshs = 0; @@ -1540,12 +1591,14 @@ namespace OpenSim.Region.ClientStack.Linden private int m_nreqmeshs; private int m_nreqinstances; private bool m_IsAtestUpload; + private bool m_avatarSkeleton; + private bool m_avatarCollider; public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, IHttpServer httpServer, bool dumpAssetsToFile, int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload) + bool IsAtestUpload,bool avatarSkeleton, bool avatarCollider) { m_assetName = assetName; m_assetDes = description; @@ -1564,6 +1617,8 @@ namespace OpenSim.Region.ClientStack.Linden m_nreqmeshs = nreqmeshs; m_nreqinstances = nreqinstances; m_IsAtestUpload = IsAtestUpload; + m_avatarSkeleton = avatarSkeleton; + m_avatarCollider = avatarCollider; m_timeoutTimer.Elapsed += TimedOut; m_timeoutTimer.Interval = 120000; @@ -1608,7 +1663,8 @@ namespace OpenSim.Region.ClientStack.Linden if (handlerUpLoad != null) { handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, - m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, ref m_error); + m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, + m_avatarSkeleton, m_avatarCollider, ref m_error); } if (m_IsAtestUpload) { diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 4a3fae6..db6f9fd 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -96,12 +96,18 @@ namespace OpenSim.Region.ClientStack.Linden // basicCost input region assets upload cost // totalcost returns model total upload fee // meshcostdata returns detailed costs for viewer - public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, - LLSDAssetUploadResponseData meshcostdata, out string error, ref string warning) + // avatarSkeleton if mesh includes a avatar skeleton + // useAvatarCollider if we should use physics mesh for avatar + public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, + LLSDAssetUploadResponseData meshcostdata,out bool avatarSkeleton, out bool useAvatarCollider, + out string error, ref string warning) { totalcost = 0; error = string.Empty; - + + avatarSkeleton = false; + useAvatarCollider = false; + if (resources == null || resources.instance_list == null || resources.instance_list.Array.Count == 0) @@ -145,6 +151,10 @@ namespace OpenSim.Region.ClientStack.Linden float meshsfee = 0; int numberMeshs = 0; bool haveMeshs = false; + + bool curskeleton; + bool curAvatarPhys; + List meshsCosts = new List(); if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) @@ -156,10 +166,20 @@ namespace OpenSim.Region.ClientStack.Linden ameshCostParam curCost = new ameshCostParam(); byte[] data = (byte[])resources.mesh_list.Array[i]; - if (!MeshCost(data, curCost, out error)) + if (!MeshCost(data, curCost,out curskeleton, out curAvatarPhys, out error)) { return false; } + + if (curskeleton) + { + if (avatarSkeleton) + { + error = "model can only contain a avatar skeleton"; + return false; + } + avatarSkeleton = true; + } meshsCosts.Add(curCost); meshsfee += curCost.costFee; } @@ -273,7 +293,7 @@ namespace OpenSim.Region.ClientStack.Linden } // single mesh asset cost - private bool MeshCost(byte[] data, ameshCostParam cost, out string error) + private bool MeshCost(byte[] data, ameshCostParam cost,out bool skeleton, out bool avatarPhys, out string error) { cost.highLODSize = 0; cost.medLODSize = 0; @@ -284,6 +304,9 @@ namespace OpenSim.Region.ClientStack.Linden error = string.Empty; + skeleton = false; + avatarPhys = false; + if (data == null || data.Length == 0) { error = "Missing model information."; @@ -330,6 +353,17 @@ namespace OpenSim.Region.ClientStack.Linden int submesh_offset = -1; + if (map.ContainsKey("skeleton")) + { + tmpmap = (OSDMap)map["skeleton"]; + if (tmpmap.ContainsKey("offset") && tmpmap.ContainsKey("size")) + { + int sksize = tmpmap["size"].AsInteger(); + if(sksize > 0) + skeleton = true; + } + } + if (map.ContainsKey("physics_convex")) { tmpmap = (OSDMap)map["physics_convex"]; -- cgit v1.1 From dab2e778d6a9d11cce48161d045598a56e7de952 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 11 Oct 2014 10:22:57 +0100 Subject: bug fix --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 3a070c3..133a629 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -830,7 +830,8 @@ namespace OpenSim.Region.ClientStack.Linden List textures = new List(); - if (doTextInv) +// if (doTextInv) + if (doTextInv || avatarSkeleton) m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); if(client == null) // don't put textures in inventory if there is no client @@ -903,7 +904,7 @@ namespace OpenSim.Region.ClientStack.Linden // test code - if (avatarSkeleton) + if (avatarSkeleton && client != null) { string name = assetName; if (name.Length > 25) -- cgit v1.1 From cc71dd9a278ffe79668336db11fb768ce881fd18 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 11 Oct 2014 11:12:43 +0100 Subject: dont let test mesh go to meshes inventory folder that is not displayed by viewers --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 133a629..344df2b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -920,7 +920,9 @@ namespace OpenSim.Region.ClientStack.Linden meshitem.Name = name; meshitem.AssetType = (int)AssetType.Mesh; meshitem.InvType = (int)InventoryType.Mesh; - meshitem.Folder = UUID.Zero; // send to default + // meshitem.Folder = UUID.Zero; // send to default + + meshitem.Folder = parentFolder; // dont let it go to folder Meshes that viewers dont show // If we set PermissionMask.All then when we rez the item the next permissions will replace the current // (owner) permissions. This becomes a problem if next permissions are changed. -- cgit v1.1 From c3e88b7b3810aace6e2260526d8f74df88d2cead Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 11 Oct 2014 22:41:59 +0100 Subject: changed skeleton, do parse the mesh on upload to check skeleton. Sooner or later this parsing needs to validate the model cost also. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 44 +++++++++++----------- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 8 ++-- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 344df2b..ab8f0c9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.ClientStack.Linden string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload, bool avatarSkeleton, bool avatarCollider, ref string error); + bool IsAtestUpload, ref string error); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -531,8 +531,6 @@ namespace OpenSim.Region.ClientStack.Linden int nreqmeshs= 0; int nreqinstances = 0; bool IsAtestUpload = false; - bool avatarSkeleton = false; - bool avatarCollider = false; string assetName = llsdRequest.name; @@ -584,7 +582,7 @@ namespace OpenSim.Region.ClientStack.Linden if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, - meshcostdata,out avatarSkeleton, out avatarCollider, out error, ref warning)) + meshcostdata, out error, ref warning)) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = error; @@ -667,7 +665,7 @@ namespace OpenSim.Region.ClientStack.Linden AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, - texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload, avatarSkeleton, avatarCollider); + texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -714,7 +712,7 @@ namespace OpenSim.Region.ClientStack.Linden UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload,bool avatarSkeleton, bool avatarCollider, ref string error) + bool IsAtestUpload, ref string error) { lock (m_ModelCost) @@ -800,7 +798,7 @@ namespace OpenSim.Region.ClientStack.Linden OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); // compare and get updated information - +/* does nothing still we do need something to avoid special viewer to upload something diferent from the cost estimation bool mismatchError = true; while (mismatchError) @@ -816,7 +814,7 @@ namespace OpenSim.Region.ClientStack.Linden return; } - +*/ OSDArray instance_list = (OSDArray)request["instance_list"]; OSDArray mesh_list = (OSDArray)request["mesh_list"]; OSDArray texture_list = (OSDArray)request["texture_list"]; @@ -831,7 +829,6 @@ namespace OpenSim.Region.ClientStack.Linden // if (doTextInv) - if (doTextInv || avatarSkeleton) m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); if(client == null) // don't put textures in inventory if there is no client @@ -879,10 +876,17 @@ namespace OpenSim.Region.ClientStack.Linden // create and store meshs assets List meshAssets = new List(); + List meshAvatarSkeletons = new List(); + List meshAvatarColliders = new List(); + + bool curAvSkeleton; + bool curAvCollider; for (int i = 0; i < mesh_list.Count; i++) { -/* - // do we really need this heavy thing? + curAvSkeleton = false; + curAvCollider = false; + + // we do need to parse the mesh now OSD osd = OSDParser.DeserializeLLSDBinary(mesh_list[i]); if (osd is OSDMap) { @@ -891,9 +895,10 @@ namespace OpenSim.Region.ClientStack.Linden { OSDMap skeleton = (OSDMap)mosd["skeleton"]; int sksize = skeleton["size"].AsInteger(); + if (sksize > 0) + curAvSkeleton = true; } } -*/ AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); meshAsset.Data = mesh_list[i].AsBinary(); @@ -901,10 +906,11 @@ namespace OpenSim.Region.ClientStack.Linden meshAsset.Local = true; m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); - + meshAvatarSkeletons.Add(curAvSkeleton); + meshAvatarColliders.Add(curAvCollider); // test code - if (avatarSkeleton && client != null) + if (curAvSkeleton && client != null) { string name = assetName; if (name.Length > 25) @@ -1594,14 +1600,12 @@ namespace OpenSim.Region.ClientStack.Linden private int m_nreqmeshs; private int m_nreqinstances; private bool m_IsAtestUpload; - private bool m_avatarSkeleton; - private bool m_avatarCollider; - + public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, IHttpServer httpServer, bool dumpAssetsToFile, int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, - bool IsAtestUpload,bool avatarSkeleton, bool avatarCollider) + bool IsAtestUpload) { m_assetName = assetName; m_assetDes = description; @@ -1620,8 +1624,6 @@ namespace OpenSim.Region.ClientStack.Linden m_nreqmeshs = nreqmeshs; m_nreqinstances = nreqinstances; m_IsAtestUpload = IsAtestUpload; - m_avatarSkeleton = avatarSkeleton; - m_avatarCollider = avatarCollider; m_timeoutTimer.Elapsed += TimedOut; m_timeoutTimer.Interval = 120000; @@ -1667,7 +1669,7 @@ namespace OpenSim.Region.ClientStack.Linden { handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, - m_avatarSkeleton, m_avatarCollider, ref m_error); + ref m_error); } if (m_IsAtestUpload) { diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index db6f9fd..546bcd9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -99,15 +99,13 @@ namespace OpenSim.Region.ClientStack.Linden // avatarSkeleton if mesh includes a avatar skeleton // useAvatarCollider if we should use physics mesh for avatar public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, - LLSDAssetUploadResponseData meshcostdata,out bool avatarSkeleton, out bool useAvatarCollider, - out string error, ref string warning) + LLSDAssetUploadResponseData meshcostdata, out string error, ref string warning) { totalcost = 0; error = string.Empty; - avatarSkeleton = false; - useAvatarCollider = false; - + bool avatarSkeleton = false; + if (resources == null || resources.instance_list == null || resources.instance_list.Array.Count == 0) -- cgit v1.1 From 39cfd823032ec83096cf3755566901f73a993fdc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 11 Oct 2014 22:53:47 +0100 Subject: add simulator features AvatarSkeleton and AnimationSet report --- OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index e4d8a20..7c22a7c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -131,8 +131,11 @@ namespace OpenSim.Region.ClientStack.Linden m_features["MeshRezEnabled"] = true; m_features["MeshUploadEnabled"] = true; m_features["MeshXferEnabled"] = true; + m_features["AvatarSkeleton"] = true; + m_features["AnimationSet"] = true; + m_features["PhysicsMaterialsEnabled"] = true; - + OSDMap typesMap = new OSDMap(); typesMap["convex"] = true; typesMap["none"] = true; -- cgit v1.1 From 9a3df6445e82453964e0604b91ad08499406a2e2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 12 Oct 2014 12:52:12 +0100 Subject: move AnimationSet and AvatarSkeleton to OpenSimExtras --- .../ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 7c22a7c..bedec80 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -131,8 +131,6 @@ namespace OpenSim.Region.ClientStack.Linden m_features["MeshRezEnabled"] = true; m_features["MeshUploadEnabled"] = true; m_features["MeshXferEnabled"] = true; - m_features["AvatarSkeleton"] = true; - m_features["AnimationSet"] = true; m_features["PhysicsMaterialsEnabled"] = true; @@ -143,15 +141,19 @@ namespace OpenSim.Region.ClientStack.Linden m_features["PhysicsShapeTypes"] = typesMap; // Extra information for viewers that want to use it - // TODO: Take these out of here into their respective modules, like map-server-url + OSDMap extrasMap = new OSDMap(); + + extrasMap["AvatarSkeleton"] = true; + extrasMap["AnimationSet"] = true; + + // TODO: Take these out of here into their respective modules, like map-server-url if (m_SearchURL != string.Empty) extrasMap["search-server-url"] = m_SearchURL; if (m_ExportSupported) extrasMap["ExportSupported"] = true; - if (extrasMap.Count > 0) - m_features["OpenSimExtras"] = extrasMap; + m_features["OpenSimExtras"] = extrasMap; } } -- cgit v1.1 From 08c72a8dc1e54114559521a6c2952905ecf6f105 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 28 Mar 2015 07:50:04 -0700 Subject: varregion: remove use of Constants.RegionSize is various places. More use of the Util routines for conversion of region handles into addresses. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index ca6c3ca..51535a6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -59,6 +59,7 @@ namespace OpenSim.Region.ClientStack.Linden public class EventQueueGetModule : IEventQueue, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static string LogHeader = "[EVENT QUEUE GET MODULE]"; /// /// Debug level. @@ -479,7 +480,7 @@ namespace OpenSim.Region.ClientStack.Linden public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) { m_log.DebugFormat("{0} EnableSimulator. handle={1}, avatarID={2}, regionSize={3},{4}>", - "[EVENT QUEUE GET MODULE]", handle, avatarID, regionSizeX, regionSizeY); + LogHeader, handle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); Enqueue(item, avatarID); @@ -489,7 +490,7 @@ namespace OpenSim.Region.ClientStack.Linden ulong regionHandle, int regionSizeX, int regionSizeY) { m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, avatarID={2}, regionSize={3},{4}>", - "[EVENT QUEUE GET MODULE]", regionHandle, avatarID, regionSizeX, regionSizeY); + LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); Enqueue(item, avatarID); } @@ -500,7 +501,7 @@ namespace OpenSim.Region.ClientStack.Linden UUID avatarID, int regionSizeX, int regionSizeY) { m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize={3},{4}>", - "[EVENT QUEUE GET MODULE]", regionHandle, avatarID, regionSizeX, regionSizeY); + LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); @@ -512,7 +513,7 @@ namespace OpenSim.Region.ClientStack.Linden string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) { m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", - "[EVENT QUEUE GET MODULE]", handle, avatarID, regionSizeX, regionSizeY); + LogHeader, handle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, capsURL, avatarID, sessionID, regionSizeX, regionSizeY); -- cgit v1.1 From 05d72f77ff38585817dead9b4a812ff97a001dce Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 18 Aug 2015 21:32:03 +0100 Subject: do keepalive on mesh and texture GET. Dont use reusecontext any where. setting of keepalive is wrong, it should follow the requested one ( or always as http1.1) only deny if needed (errors). KeepAlive may increase stress on number of avaiable file descritors. --- OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 4 ++-- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index a381a1b..4c15ad8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -264,7 +264,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; - response["keepalive"] = false; + response["keepalive"] = true; response["reusecontext"] = false; return response; @@ -285,7 +285,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; - response["keepalive"] = false; + response["keepalive"] = true; response["reusecontext"] = false; lock (responses) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index e053054..656f177 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -283,7 +283,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; - response["keepalive"] = false; + response["keepalive"] = true; response["reusecontext"] = false; return response; @@ -303,7 +303,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 503; response["str_response_string"] = "Throttled"; response["content_type"] = "text/plain"; - response["keepalive"] = false; + response["keepalive"] = true; response["reusecontext"] = false; lock (responses) @@ -320,7 +320,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; - response["keepalive"] = false; + response["keepalive"] = true; response["reusecontext"] = false; lock (responses) -- cgit v1.1 From fd82a0a0b79b9c0a817b887e7577e1094135dcd6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Aug 2015 00:26:43 +0100 Subject: add a Retry-After response header to the 503 sent when we are 2 busy to do the request. just 503 could mean server down (?) --- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 656f177..54e8d76 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -300,11 +300,16 @@ namespace OpenSim.Region.ClientStack.Linden { response = new Hashtable(); + response["int_response_code"] = 503; response["str_response_string"] = "Throttled"; response["content_type"] = "text/plain"; response["keepalive"] = true; response["reusecontext"] = false; + + Hashtable headers = new Hashtable(); + headers["Retry-After"] = 30; + response["headers"] = headers; lock (responses) responses[requestID] = new aPollResponse() {bytes = 0, response = response}; -- cgit v1.1 From 018d855f2840988163519ca941a373c77997c689 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 24 Aug 2015 07:38:33 +0100 Subject: turn off KeepAlive --- OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 4 ++-- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 4c15ad8..a381a1b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -264,7 +264,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; - response["keepalive"] = true; + response["keepalive"] = false; response["reusecontext"] = false; return response; @@ -285,7 +285,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; - response["keepalive"] = true; + response["keepalive"] = false; response["reusecontext"] = false; lock (responses) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 54e8d76..99ccd4b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -283,7 +283,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; - response["keepalive"] = true; + response["keepalive"] = false; response["reusecontext"] = false; return response; @@ -304,7 +304,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 503; response["str_response_string"] = "Throttled"; response["content_type"] = "text/plain"; - response["keepalive"] = true; + response["keepalive"] = false; response["reusecontext"] = false; Hashtable headers = new Hashtable(); @@ -325,7 +325,7 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; - response["keepalive"] = true; + response["keepalive"] = false; response["reusecontext"] = false; lock (responses) -- cgit v1.1 From c7ddb790a7b97115874f74a055e1d0c192eb8ef2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 27 Aug 2015 04:45:16 +0100 Subject: change osd encoding of region size --- .../Linden/Caps/EventQueue/EventQueueHelper.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 3fb7de2..50e22f5 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -77,8 +77,8 @@ namespace OpenSim.Region.ClientStack.Linden llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); - llsdSimInfo.Add("RegionSizeX", new OSDInteger(regionSizeX)); - llsdSimInfo.Add("RegionSizeY", new OSDInteger(regionSizeY)); + llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); + llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); OSDArray arr = new OSDArray(1); arr.Add(llsdSimInfo); @@ -138,8 +138,8 @@ namespace OpenSim.Region.ClientStack.Linden regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); - regionDataMap.Add("RegionSizeX", new OSDInteger(regionSizeX)); - regionDataMap.Add("RegionSizeY", new OSDInteger(regionSizeY)); + regionDataMap.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); + regionDataMap.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); OSDArray regionDataArr = new OSDArray(1); regionDataArr.Add(regionDataMap); @@ -173,8 +173,8 @@ namespace OpenSim.Region.ClientStack.Linden info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); // info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation info.Add("TeleportFlags", OSD.FromUInteger(flags)); - info.Add("RegionSizeX", new OSDInteger(regionSizeX)); - info.Add("RegionSizeY", new OSDInteger(regionSizeY)); + info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); + info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); OSDArray infoArr = new OSDArray(); infoArr.Add(info); @@ -211,8 +211,8 @@ namespace OpenSim.Region.ClientStack.Linden {"sim-ip-and-port", new OSDString(simIpAndPort)}, {"seed-capability", new OSDString(seedcap)}, {"region-handle", OSD.FromULong(regionHandle)}, - {"region-size-x", OSD.FromInteger(regionSizeX)}, - {"region-size-y", OSD.FromInteger(regionSizeY)} + {"region-size-x", OSD.FromUInteger((uint)regionSizeX)}, + {"region-size-y", OSD.FromUInteger((uint)regionSizeY)} }; return BuildEvent("EstablishAgentCommunication", body); -- cgit v1.1