Merge branch 'master' into careminster

Conflicts:
	OpenSim/Data/MySQL/MySQLSimulationData.cs
	OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
	OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
	OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
avinationmerge
Melanie 2012-08-31 01:32:18 +01:00
commit 1b15144208
16 changed files with 573 additions and 297 deletions

View File

@ -135,14 +135,25 @@
<delete dir="%temp%"/>
</target>
<target name="torture" depends="build, find-nunit">
<target name="test-stress" depends="build, find-nunit">
<setenv name="MONO_THREADS_PER_CPU" value="100" />
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.torture">
<arg value="./bin/OpenSim.Tests.Torture.dll" />
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.stress">
<arg value="./bin/OpenSim.Tests.Stress.dll" />
</exec>
<fail message="Failures reported in unit tests." unless="${int::parse(testresult.opensim.tests.torture)==0}" />
<fail message="Failures reported in stress tests." unless="${int::parse(testresult.opensim.tests.stress)==0}" />
<delete dir="%temp%"/>
</target>
<target name="test-perf" depends="build, find-nunit">
<setenv name="MONO_THREADS_PER_CPU" value="100" />
<exec program="${nunitcmd}" failonerror="true" resultproperty="testresult.opensim.tests.performance">
<arg value="./bin/OpenSim.Tests.Performance.dll" />
</exec>
<fail message="Failures reported in performance tests." unless="${int::parse(testresult.opensim.tests.performance)==0}" />
<delete dir="%temp%"/>
</target>

View File

@ -747,6 +747,8 @@ namespace OpenSim.Data.MySQL
RegionLightShareData nWP = new RegionLightShareData();
nWP.OnSave += StoreRegionWindlightSettings;
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
@ -836,6 +838,8 @@ namespace OpenSim.Data.MySQL
}
}
}
}
return nWP;
}
@ -880,6 +884,8 @@ namespace OpenSim.Data.MySQL
}
public virtual void StoreRegionWindlightSettings(RegionLightShareData wl)
{
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
@ -981,8 +987,11 @@ namespace OpenSim.Data.MySQL
}
}
}
}
public virtual void RemoveRegionWindlightSettings(UUID regionID)
{
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
@ -996,9 +1005,12 @@ namespace OpenSim.Data.MySQL
}
}
}
}
#region RegionEnvironmentSettings
public string LoadRegionEnvironmentSettings(UUID regionUUID)
{
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
@ -1024,8 +1036,11 @@ namespace OpenSim.Data.MySQL
}
}
}
}
public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
{
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
@ -1042,8 +1057,11 @@ namespace OpenSim.Data.MySQL
}
}
}
}
public void RemoveRegionEnvironmentSettings(UUID regionUUID)
{
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
@ -1057,6 +1075,7 @@ namespace OpenSim.Data.MySQL
}
}
}
}
#endregion
public virtual void StoreRegionSettings(RegionSettings rs)

View File

@ -186,8 +186,20 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face)
{
if (RenderPlugins.ContainsKey(contentType))
{
if (!RenderPlugins.ContainsKey(contentType))
return UUID.Zero;
Scene scene;
RegisteredScenes.TryGetValue(simID, out scene);
if (scene == null)
return UUID.Zero;
SceneObjectPart part = scene.GetSceneObjectPart(primID);
if (part == null)
return UUID.Zero;
// If we want to reuse dynamic textures then we have to ignore any request from the caller to expire
// them.
if (ReuseTextures)
@ -207,14 +219,27 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.Url = "Local image";
updater.Disp = disp;
object reusableTextureUUID = null;
object objReusableTextureUUID = null;
if (ReuseTextures)
reusableTextureUUID
= m_reuseableDynamicTextures.Get(GenerateReusableTextureKey(data, extraParams));
if (ReuseTextures && !updater.BlendWithOldTexture)
{
string reuseableTextureKey = GenerateReusableTextureKey(data, extraParams);
objReusableTextureUUID = m_reuseableDynamicTextures.Get(reuseableTextureKey);
if (objReusableTextureUUID != null)
{
// If something else has removed this temporary asset from the cache, detect and invalidate
// our cached uuid.
if (scene.AssetService.GetMetadata(objReusableTextureUUID.ToString()) == null)
{
m_reuseableDynamicTextures.Invalidate(reuseableTextureKey);
objReusableTextureUUID = null;
}
}
}
// We cannot reuse a dynamic texture if the data is going to be blended with something already there.
if (reusableTextureUUID == null || updater.BlendWithOldTexture)
if (objReusableTextureUUID == null)
{
lock (Updaters)
{
@ -230,21 +255,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
{
// No need to add to updaters as the texture is always the same. Not that this functionality
// apppears to be implemented anyway.
if (RegisteredScenes.ContainsKey(updater.SimUUID))
{
SceneObjectPart part = RegisteredScenes[updater.SimUUID].GetSceneObjectPart(updater.PrimID);
if (part != null)
updater.UpdatePart(part, (UUID)reusableTextureUUID);
}
updater.UpdatePart(part, (UUID)objReusableTextureUUID);
}
return updater.UpdaterID;
}
return UUID.Zero;
}
private string GenerateReusableTextureKey(string data, string extraParams)
{
return string.Format("{0}{1}", data, extraParams);
@ -267,6 +283,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public void Initialise(Scene scene, IConfigSource config)
{
IConfig texturesConfig = config.Configs["Textures"];
if (texturesConfig != null)
ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false);
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
@ -276,7 +296,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public void PostInitialise()
{
// ReuseTextures = true;
if (ReuseTextures)
{
m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative);

View File

@ -58,6 +58,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public string body;
public int responseCode;
public string responseBody;
public string responseType = "text/plain";
//public ManualResetEvent ev;
public bool requestDone;
public int startTime;
@ -270,6 +271,22 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
}
}
public void HttpContentType(UUID request, string type)
{
lock (m_UrlMap)
{
if (m_RequestMap.ContainsKey(request))
{
UrlData urlData = m_RequestMap[request];
urlData.requests[request].responseType = type;
}
else
{
m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
}
}
}
public void HttpResponse(UUID request, int status, string body)
{
lock (m_RequestMap)

View File

@ -39,6 +39,8 @@ namespace OpenSim.Region.Framework.Interfaces
UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID);
void ReleaseURL(string url);
void HttpResponse(UUID request, int status, string body);
void HttpContentType(UUID request, string type);
string GetHttpHeader(UUID request, string header);
int GetFreeUrls();

View File

@ -10903,31 +10903,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Float llListStatistics(int operation, LSL_List src)
{
m_host.AddScriptLPS(1);
LSL_List nums = LSL_List.ToDoubleList(src);
switch (operation)
{
case ScriptBaseClass.LIST_STAT_RANGE:
return nums.Range();
return src.Range();
case ScriptBaseClass.LIST_STAT_MIN:
return nums.Min();
return src.Min();
case ScriptBaseClass.LIST_STAT_MAX:
return nums.Max();
return src.Max();
case ScriptBaseClass.LIST_STAT_MEAN:
return nums.Mean();
return src.Mean();
case ScriptBaseClass.LIST_STAT_MEDIAN:
return nums.Median();
return LSL_List.ToDoubleList(src).Median();
case ScriptBaseClass.LIST_STAT_NUM_COUNT:
return nums.NumericLength();
return src.NumericLength();
case ScriptBaseClass.LIST_STAT_STD_DEV:
return nums.StdDev();
return src.StdDev();
case ScriptBaseClass.LIST_STAT_SUM:
return nums.Sum();
return src.Sum();
case ScriptBaseClass.LIST_STAT_SUM_SQUARES:
return nums.SumSqrs();
return src.SumSqrs();
case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN:
return nums.GeometricMean();
return src.GeometricMean();
case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN:
return nums.HarmonicMean();
return src.HarmonicMean();
default:
return 0.0;
}

View File

@ -141,6 +141,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal bool m_debuggerSafe = false;
internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
protected IUrlModule m_UrlModule = null;
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
{
m_ScriptEngine = ScriptEngine;
@ -148,6 +150,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_item = item;
m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
m_OSFunctionsEnabled = true;
@ -3406,5 +3410,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
}
/// <summary>
/// Sets the response type for an HTTP request/response
/// </summary>
/// <returns></returns>
public void osSetContentType(LSL_Key id, string type)
{
CheckThreatLevel(ThreatLevel.High,"osSetResponseType");
if (m_UrlModule != null)
m_UrlModule.HttpContentType(new UUID(id),type);
}
}
}

View File

@ -365,5 +365,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// </summary>
/// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns>
LSL_Key osGetRezzingObject();
/// <summary>
/// Sets the response type for an HTTP request/response
/// </summary>
/// <returns></returns>
void osSetContentType(LSL_Key id, string type);
}
}

View File

@ -955,5 +955,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osGetRezzingObject();
}
public void osSetContentType(LSL_Key id, string type)
{
m_OSSL_Functions.osSetContentType(id,type);
}
}
}

View File

@ -47,10 +47,10 @@ using OpenSim.Services.AvatarService;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Tests.Torture
namespace OpenSim.Tests.Performance
{
/// <summary>
/// NPC torture tests
/// NPC performance tests
/// </summary>
/// <remarks>
/// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
@ -58,7 +58,7 @@ namespace OpenSim.Tests.Torture
/// earlier tests.
/// </remarks>
[TestFixture]
public class NPCTortureTests
public class NPCPerformanceTests
{
private TestScene scene;
private AvatarFactoryModule afm;

View File

@ -36,10 +36,10 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Tests.Torture
namespace OpenSim.Tests.Performance
{
/// <summary>
/// Object torture tests
/// Object performance tests
/// </summary>
/// <remarks>
/// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
@ -47,7 +47,7 @@ namespace OpenSim.Tests.Torture
/// earlier tests.
/// </remarks>
[TestFixture]
public class ObjectTortureTests
public class ObjectPerformanceTests
{
[TearDown]
public void TearDown()

View File

@ -42,10 +42,10 @@ using OpenSim.Region.ScriptEngine.XEngine;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Tests.Torture
namespace OpenSim.Tests.Performance
{
/// <summary>
/// Script torture tests
/// Script performance tests
/// </summary>
/// <remarks>
/// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
@ -53,7 +53,7 @@ namespace OpenSim.Tests.Torture
/// earlier tests.
/// </remarks>
[TestFixture]
public class ScriptTortureTests
public class ScriptPerformanceTests
{
private TestScene m_scene;
private XEngine m_xEngine;

View File

@ -0,0 +1,132 @@
/*
* 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.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using log4net.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenMetaverse.Assets;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
using OpenSim.Region.CoreModules.Scripting.VectorRender;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Tests.Stress
{
[TestFixture]
public class VectorRenderModuleStressTests : OpenSimTestCase
{
public Scene Scene { get; private set; }
public DynamicTextureModule Dtm { get; private set; }
public VectorRenderModule Vrm { get; private set; }
private void SetupScene(bool reuseTextures)
{
Scene = new SceneHelpers().SetupScene();
Dtm = new DynamicTextureModule();
Dtm.ReuseTextures = reuseTextures;
Vrm = new VectorRenderModule();
SceneHelpers.SetupSceneModules(Scene, Dtm, Vrm);
}
[Test]
public void TestConcurrentRepeatedDraw()
{
int threads = 4;
TestHelpers.InMethod();
SetupScene(false);
List<Drawer> drawers = new List<Drawer>();
for (int i = 0; i < threads; i++)
{
Drawer d = new Drawer(this, i);
drawers.Add(d);
Console.WriteLine("Starting drawer {0}", i);
Util.FireAndForget(o => d.Draw());
}
Thread.Sleep(10 * 60 * 1000);
drawers.ForEach(d => d.Ready = false);
drawers.ForEach(d => Console.WriteLine("Drawer {0} drew {1} textures", d.Number, d.Pass + 1));
}
class Drawer
{
public int Number { get; private set; }
public int Pass { get; private set; }
public bool Ready { get; set; }
private VectorRenderModuleStressTests m_tests;
public Drawer(VectorRenderModuleStressTests tests, int number)
{
m_tests = tests;
Number = number;
Ready = true;
}
public void Draw()
{
SceneObjectGroup so = SceneHelpers.AddSceneObject(m_tests.Scene);
while (Ready)
{
UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
// Ensure unique text
string text = string.Format("{0:D2}{1}", Number, Pass);
m_tests.Dtm.AddDynamicTextureData(
m_tests.Scene.RegionInfo.RegionID,
so.UUID,
m_tests.Vrm.GetContentType(),
string.Format("PenColour BLACK; MoveTo 40,220; FontSize 32; Text {0};", text),
"",
0);
Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
Pass++;
}
}
}
}
}

View File

@ -693,6 +693,17 @@
;LevelUpload = 0
[Textures]
; If true, textures generated dynamically (i.e. through osSetDynamicTextureData() and similar OSSL functions) are reused where possible
; Chiefly, reuse occurs if a texture has already been generated with identical data and settings, and that texture contains no dynamic components
; (e.g. images pulled from an external HTTP address).
; Reusing previously generated textures results in a much faster update on the viewer but may cause issues if the viewer didn't receive all resolutions of the texture.
; Currently, it will also increase asset cache use since temporary dynamic textures are no longer deleted.
; Hence, currently considered experimental.
; Default is false.
ReuseDynamicTextures = false
[ODEPhysicsSettings]
; ##
; ## Physics stats settings

View File

@ -3371,7 +3371,47 @@
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Torture" path="OpenSim/Tests/Torture" type="Library">
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Stress" path="OpenSim/Tests/Stress" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Xml"/>
<Reference name="System.Data"/>
<Reference name="log4net" path="../../../bin/"/>
<Reference name="Nini" path="../../../bin/"/>
<Reference name="nunit.framework" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
<Reference name="XMLRPC" path="../../../bin/"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.OptionalModules"/>
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
<Reference name="OpenSim.Region.ScriptEngine.XEngine"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.AvatarService"/>
<Reference name="OpenSim.Tests.Common"/>
<Files>
<Match pattern="*.cs" recurse="false"/>
</Files>
</Project>
<Project frameworkVersion="v3_5" name="OpenSim.Tests.Performance" path="OpenSim/Tests/Performance" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>