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. --- OpenSim/Framework/AssetPermissions.cs | 84 ----- OpenSim/Framework/AvatarAppearance.cs | 3 - OpenSim/Framework/Cache.cs | 83 ++--- OpenSim/Framework/Client/IClientChat.cs | 7 +- OpenSim/Framework/Console/ConsoleUtil.cs | 228 ------------ OpenSim/Framework/Constants.cs | 1 - OpenSim/Framework/EstateSettings.cs | 10 +- OpenSim/Framework/GridInstantMessage.cs | 9 +- OpenSim/Framework/IClientAPI.cs | 46 +-- OpenSim/Framework/InventoryFolderBase.cs | 18 +- OpenSim/Framework/LandData.cs | 385 +++++++-------------- OpenSim/Framework/Monitoring/BaseStatsCollector.cs | 23 +- OpenSim/Framework/Monitoring/MemoryWatchdog.cs | 10 +- .../Framework/Monitoring/SimExtraStatsCollector.cs | 19 +- OpenSim/Framework/Monitoring/StatsManager.cs | 360 ------------------- OpenSim/Framework/Monitoring/Watchdog.cs | 35 +- OpenSim/Framework/PacketPool.cs | 247 +++++++++++++ OpenSim/Framework/Pool.cs | 91 ----- OpenSim/Framework/RegionFlags.cs | 53 --- OpenSim/Framework/RegionInfo.cs | 72 +--- .../Framework/Serialization/ArchiveConstants.cs | 5 - .../Serialization/External/OspResolver.cs | 14 +- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 43 ++- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 274 ++++++--------- .../Servers/HttpServer/Interfaces/IHttpServer.cs | 22 +- OpenSim/Framework/Servers/MainServer.cs | 148 +------- OpenSim/Framework/Servers/VersionInfo.cs | 2 +- OpenSim/Framework/TaskInventoryDictionary.cs | 4 +- OpenSim/Framework/TaskInventoryItem.cs | 19 +- OpenSim/Framework/Util.cs | 51 --- OpenSim/Framework/WebUtil.cs | 81 +---- 31 files changed, 639 insertions(+), 1808 deletions(-) delete mode 100644 OpenSim/Framework/AssetPermissions.cs delete mode 100644 OpenSim/Framework/Console/ConsoleUtil.cs create mode 100644 OpenSim/Framework/PacketPool.cs delete mode 100644 OpenSim/Framework/Pool.cs delete mode 100644 OpenSim/Framework/RegionFlags.cs (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AssetPermissions.cs b/OpenSim/Framework/AssetPermissions.cs deleted file mode 100644 index 4a905c2..0000000 --- a/OpenSim/Framework/AssetPermissions.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; - -using Nini.Config; -using log4net; - -using OpenMetaverse; - -namespace OpenSim.Framework -{ - public class AssetPermissions - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private bool[] m_DisallowExport, m_DisallowImport; - private string[] m_AssetTypeNames; - - public AssetPermissions(IConfig config) - { - Type enumType = typeof(AssetType); - m_AssetTypeNames = Enum.GetNames(enumType); - for (int i = 0; i < m_AssetTypeNames.Length; i++) - m_AssetTypeNames[i] = m_AssetTypeNames[i].ToLower(); - int n = Enum.GetValues(enumType).Length; - m_DisallowExport = new bool[n]; - m_DisallowImport = new bool[n]; - - LoadPermsFromConfig(config, "DisallowExport", m_DisallowExport); - LoadPermsFromConfig(config, "DisallowImport", m_DisallowImport); - - } - - private void LoadPermsFromConfig(IConfig assetConfig, string variable, bool[] bitArray) - { - if (assetConfig == null) - return; - - string perms = assetConfig.GetString(variable, String.Empty); - string[] parts = perms.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - foreach (string s in parts) - { - int index = Array.IndexOf(m_AssetTypeNames, s.Trim().ToLower()); - if (index >= 0) - bitArray[index] = true; - else - m_log.WarnFormat("[Asset Permissions]: Invalid AssetType {0}", s); - } - - } - - public bool AllowedExport(sbyte type) - { - string assetTypeName = ((AssetType)type).ToString(); - - int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower()); - if (index >= 0 && m_DisallowExport[index]) - { - m_log.DebugFormat("[Asset Permissions]: Export denied: configuration does not allow export of AssetType {0}", assetTypeName); - return false; - } - - return true; - } - - public bool AllowedImport(sbyte type) - { - string assetTypeName = ((AssetType)type).ToString(); - - int index = Array.IndexOf(m_AssetTypeNames, assetTypeName.ToLower()); - if (index >= 0 && m_DisallowImport[index]) - { - m_log.DebugFormat("[Asset Permissions]: Import denied: configuration does not allow import of AssetType {0}", assetTypeName); - return false; - } - - return true; - } - - - } -} diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 1638541..c5d9641 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -358,9 +358,6 @@ namespace OpenSim.Framework SetVisualParams(visualParams); } - /// - /// Set avatar height by a calculation based on their visual parameters. - /// public virtual void SetHeight() { // Start with shortest possible female avatar height diff --git a/OpenSim/Framework/Cache.cs b/OpenSim/Framework/Cache.cs index 31cab4a..79e20fc 100644 --- a/OpenSim/Framework/Cache.cs +++ b/OpenSim/Framework/Cache.cs @@ -199,14 +199,7 @@ namespace OpenSim.Framework // public class Cache { - /// - /// Must only be accessed under lock. - /// private List m_Index = new List(); - - /// - /// Must only be accessed under m_Index lock. - /// private Dictionary m_Lookup = new Dictionary(); @@ -327,19 +320,19 @@ namespace OpenSim.Framework { if (m_Lookup.ContainsKey(index)) item = m_Lookup[index]; + } - if (item == null) - { - Expire(true); - return null; - } - - item.hits++; - item.lastUsed = DateTime.Now; - + if (item == null) + { Expire(true); + return null; } + item.hits++; + item.lastUsed = DateTime.Now; + + Expire(true); + return item; } @@ -392,10 +385,7 @@ namespace OpenSim.Framework // public Object Find(Predicate d) { - CacheItemBase item; - - lock (m_Index) - item = m_Index.Find(d); + CacheItemBase item = m_Index.Find(d); if (item == null) return null; @@ -429,12 +419,12 @@ namespace OpenSim.Framework public virtual void Store(string index, Object data, Type container, Object[] parameters) { + Expire(false); + CacheItemBase item; lock (m_Index) { - Expire(false); - if (m_Index.Contains(new CacheItemBase(index))) { if ((m_Flags & CacheFlags.AllowUpdate) != 0) @@ -460,17 +450,9 @@ namespace OpenSim.Framework m_Index.Add(item); m_Lookup[index] = item; } - item.Store(data); } - /// - /// Expire items as appropriate. - /// - /// - /// Callers must lock m_Index. - /// - /// protected virtual void Expire(bool getting) { if (getting && (m_Strategy == CacheStrategy.Aggressive)) @@ -493,10 +475,12 @@ namespace OpenSim.Framework switch (m_Strategy) { - case CacheStrategy.Aggressive: - if (Count < Size) - return; + case CacheStrategy.Aggressive: + if (Count < Size) + return; + lock (m_Index) + { m_Index.Sort(new SortLRU()); m_Index.Reverse(); @@ -506,7 +490,7 @@ namespace OpenSim.Framework ExpireDelegate doExpire = OnExpire; - if (doExpire != null) + if (doExpire != null) { List candidates = m_Index.GetRange(target, Count - target); @@ -529,34 +513,27 @@ namespace OpenSim.Framework foreach (CacheItemBase item in m_Index) m_Lookup[item.uuid] = item; } - - break; - - default: - break; + } + break; + default: + break; } } public void Invalidate(string uuid) { - lock (m_Index) - { - if (!m_Lookup.ContainsKey(uuid)) - return; + if (!m_Lookup.ContainsKey(uuid)) + return; - CacheItemBase item = m_Lookup[uuid]; - m_Lookup.Remove(uuid); - m_Index.Remove(item); - } + CacheItemBase item = m_Lookup[uuid]; + m_Lookup.Remove(uuid); + m_Index.Remove(item); } public void Clear() { - lock (m_Index) - { - m_Index.Clear(); - m_Lookup.Clear(); - } + m_Index.Clear(); + m_Lookup.Clear(); } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Client/IClientChat.cs b/OpenSim/Framework/Client/IClientChat.cs index 86b1faa..078ea9b 100644 --- a/OpenSim/Framework/Client/IClientChat.cs +++ b/OpenSim/Framework/Client/IClientChat.cs @@ -33,8 +33,7 @@ namespace OpenSim.Framework.Client { event ChatMessage OnChatFromClient; - void SendChatMessage( - string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, - byte audible); + void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, + byte audible); } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs deleted file mode 100644 index 16a63e0..0000000 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ /dev/null @@ -1,228 +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.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using log4net; -using OpenMetaverse; - -namespace OpenSim.Framework.Console -{ - public class ConsoleUtil - { - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public const int LocalIdNotFound = 0; - - /// - /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section - /// rather than in each help summary. - /// - public const string CoordHelp - = @"Each component of the coord is comma separated. There must be no spaces between the commas. - If you don't care about the z component you can simply omit it. - If you don't care about the x or y components then you can leave them blank (though a comma is still required) - If you want to specify the maxmimum value of a component then you can use ~ instead of a number - If you want to specify the minimum value of a component then you can use -~ instead of a number - e.g. - delete object pos 20,20,20 to 40,40,40 - delete object pos 20,20 to 40,40 - delete object pos ,20,20 to ,40,40 - delete object pos ,,30 to ,,~ - delete object pos ,,-~ to ,,30"; - - public const string MinRawConsoleVectorValue = "-~"; - public const string MaxRawConsoleVectorValue = "~"; - - public const string VectorSeparator = ","; - public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); - - /// - /// Check if the given file path exists. - /// - /// If not, warning is printed to the given console. - /// true if the file does not exist, false otherwise. - /// - /// - public static bool CheckFileDoesNotExist(ICommandConsole console, string path) - { - if (File.Exists(path)) - { - console.OutputFormat("File {0} already exists. Please move or remove it.", path); - return false; - } - - return true; - } - - /// - /// Try to parse a console UUID from the console. - /// - /// - /// Will complain to the console if parsing fails. - /// - /// - /// If null then no complaint is printed. - /// - /// - public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid) - { - if (!UUID.TryParse(rawUuid, out uuid)) - { - if (console != null) - console.OutputFormat("{0} is not a valid uuid", rawUuid); - - return false; - } - - return true; - } - - public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId) - { - if (!uint.TryParse(rawLocalId, out localId)) - { - if (console != null) - console.OutputFormat("{0} is not a valid local id", localId); - - return false; - } - - if (localId == 0) - { - if (console != null) - console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId); - - return false; - } - - return true; - } - - /// - /// Tries to parse the input as either a UUID or a local ID. - /// - /// true if parsing succeeded, false otherwise. - /// - /// - /// - /// - /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded. - /// - public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId) - { - if (TryParseConsoleUuid(null, rawId, out uuid)) - { - localId = LocalIdNotFound; - return true; - } - - if (TryParseConsoleLocalId(null, rawId, out localId)) - { - return true; - } - - if (console != null) - console.OutputFormat("{0} is not a valid UUID or local id", rawId); - - return false; - } - - /// - /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 - /// - /// /param> - /// - /// - public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector) - { - return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector); - } - - /// - /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3 - /// - /// /param> - /// - /// - public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector) - { - return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector); - } - - /// - /// Convert a vector input from the console to an OpenMetaverse.Vector3 - /// - /// - /// A string in the form ,, where there is no space between values. - /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value - /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40) - /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue - /// Other than that, component values must be numeric. - /// - /// - /// - /// - public static bool TryParseConsoleVector( - string rawConsoleVector, Func blankComponentFunc, out Vector3 vector) - { - List components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); - - if (components.Count < 1 || components.Count > 3) - { - vector = Vector3.Zero; - return false; - } - - for (int i = components.Count; i < 3; i++) - components.Add(""); - - List semiDigestedComponents - = components.ConvertAll( - c => - { - if (c == "") - return blankComponentFunc.Invoke(c); - else if (c == MaxRawConsoleVectorValue) - return float.MaxValue.ToString(); - else if (c == MinRawConsoleVectorValue) - return float.MinValue.ToString(); - else - return c; - }); - - string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); - - // m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); - - return Vector3.TryParse(semiDigestedConsoleVector, out vector); - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs index a2eb5ee..1b1aaf2 100644 --- a/OpenSim/Framework/Constants.cs +++ b/OpenSim/Framework/Constants.cs @@ -31,7 +31,6 @@ namespace OpenSim.Framework public class Constants { public const uint RegionSize = 256; - public const uint RegionHeight = 4096; public const byte TerrainPatchSize = 16; public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index e03750b..9020761 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -419,11 +419,11 @@ namespace OpenSim.Framework public void SetFromFlags(ulong regionFlags) { - ResetHomeOnTeleport = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport) == (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport); - BlockDwell = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.BlockDwell) == (ulong)OpenMetaverse.RegionFlags.BlockDwell); - AllowLandmark = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowLandmark) == (ulong)OpenMetaverse.RegionFlags.AllowLandmark); - AllowParcelChanges = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges) == (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges); - AllowSetHome = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowSetHome) == (ulong)OpenMetaverse.RegionFlags.AllowSetHome); + ResetHomeOnTeleport = ((regionFlags & (ulong)RegionFlags.ResetHomeOnTeleport) == (ulong)RegionFlags.ResetHomeOnTeleport); + BlockDwell = ((regionFlags & (ulong)RegionFlags.BlockDwell) == (ulong)RegionFlags.BlockDwell); + AllowLandmark = ((regionFlags & (ulong)RegionFlags.AllowLandmark) == (ulong)RegionFlags.AllowLandmark); + AllowParcelChanges = ((regionFlags & (ulong)RegionFlags.AllowParcelChanges) == (ulong)RegionFlags.AllowParcelChanges); + AllowSetHome = ((regionFlags & (ulong)RegionFlags.AllowSetHome) == (ulong)RegionFlags.AllowSetHome); } public bool GroupAccess(UUID groupID) diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs index 6ae0488..a6bf6e3 100644 --- a/OpenSim/Framework/GridInstantMessage.cs +++ b/OpenSim/Framework/GridInstantMessage.cs @@ -44,6 +44,7 @@ namespace OpenSim.Framework public Vector3 Position; public byte[] binaryBucket; + public uint ParentEstateID; public Guid RegionID; public uint timestamp; @@ -57,7 +58,7 @@ namespace OpenSim.Framework string _fromAgentName, UUID _toAgentID, byte _dialog, bool _fromGroup, string _message, UUID _imSessionID, bool _offline, Vector3 _position, - byte[] _binaryBucket, bool addTimestamp) + byte[] _binaryBucket) { fromAgentID = _fromAgentID.Guid; fromAgentName = _fromAgentName; @@ -78,9 +79,7 @@ namespace OpenSim.Framework ParentEstateID = scene.RegionInfo.EstateSettings.ParentEstateID; RegionID = scene.RegionInfo.RegionSettings.RegionUUID.Guid; } - - if (addTimestamp) - timestamp = (uint)Util.UnixTimeSinceEpoch(); + timestamp = (uint)Util.UnixTimeSinceEpoch(); } public GridInstantMessage(IScene scene, UUID _fromAgentID, @@ -88,7 +87,7 @@ namespace OpenSim.Framework string _message, bool _offline, Vector3 _position) : this(scene, _fromAgentID, _fromAgentName, _toAgentID, _dialog, false, _message, - _fromAgentID ^ _toAgentID, _offline, _position, new byte[0], true) + _fromAgentID ^ _toAgentID, _offline, _position, new byte[0]) { } } diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 1c6685a..e31c7f6 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -815,23 +815,8 @@ namespace OpenSim.Framework event Action OnRegionHandShakeReply; event GenericCall1 OnRequestWearables; event Action OnCompleteMovementToRegion; - - /// - /// Called when an AgentUpdate message is received and before OnAgentUpdate. - /// - /// - /// Listeners must not retain a reference to AgentUpdateArgs since this object may be reused for subsequent AgentUpdates. - /// event UpdateAgent OnPreAgentUpdate; - - /// - /// Called when an AgentUpdate message is received and after OnPreAgentUpdate. - /// - /// - /// Listeners must not retain a reference to AgentUpdateArgs since this object may be reused for subsequent AgentUpdates. - /// event UpdateAgent OnAgentUpdate; - event AgentRequestSit OnAgentRequestSit; event AgentSit OnAgentSit; event AvatarPickerRequest OnAvatarPickerRequest; @@ -1061,21 +1046,8 @@ namespace OpenSim.Framework void InPacket(object NewPack); void ProcessInPacket(Packet NewPack); - - /// - /// Close this client - /// void Close(); - - /// - /// Close this client - /// - /// - /// If true, attempts the close without checking active status. You do not want to try this except as a last - /// ditch attempt where Active == false but the ScenePresence still exists. - /// - void Close(bool sendStop, bool force); - + void Close(bool sendStop); void Kick(string message); /// @@ -1112,20 +1084,8 @@ namespace OpenSim.Framework void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs); void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args); - /// - /// Send chat to the viewer. - /// - /// - /// - /// - /// - /// - /// - /// - /// - void SendChatMessage( - string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, - byte audible); + void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, + byte audible); void SendInstantMessage(GridInstantMessage im); diff --git a/OpenSim/Framework/InventoryFolderBase.cs b/OpenSim/Framework/InventoryFolderBase.cs index b3457a6..a12183c 100644 --- a/OpenSim/Framework/InventoryFolderBase.cs +++ b/OpenSim/Framework/InventoryFolderBase.cs @@ -73,27 +73,33 @@ namespace OpenSim.Framework { } - public InventoryFolderBase(UUID id) : this() + public InventoryFolderBase(UUID id) { ID = id; } - public InventoryFolderBase(UUID id, UUID owner) : this(id) + public InventoryFolderBase(UUID id, UUID owner) { + ID = id; Owner = owner; } - public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent) : this(id, owner) + public InventoryFolderBase(UUID id, string name, UUID owner, UUID parent) { + ID = id; Name = name; + Owner = owner; ParentID = parent; } - public InventoryFolderBase( - UUID id, string name, UUID owner, short type, UUID parent, ushort version) : this(id, name, owner, parent) + public InventoryFolderBase(UUID id, string name, UUID owner, short type, UUID parent, ushort version) { + ID = id; + Name = name; + Owner = owner; Type = type; + ParentID = parent; Version = version; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs index 4dffd3f..dcaa46d 100644 --- a/OpenSim/Framework/LandData.cs +++ b/OpenSim/Framework/LandData.cs @@ -49,8 +49,8 @@ namespace OpenSim.Framework // use only one serializer to give the runtime a chance to // optimize it (it won't do that if you use a new instance // every time) - private static XmlSerializer serializer = new XmlSerializer(typeof(LandData)); - + private static XmlSerializer serializer = new XmlSerializer(typeof (LandData)); + private Vector3 _AABBMax = new Vector3(); private Vector3 _AABBMin = new Vector3(); private int _area = 0; @@ -65,11 +65,11 @@ namespace OpenSim.Framework private byte[] _bitmap = new byte[512]; private string _description = String.Empty; - private uint _flags = (uint)ParcelFlags.AllowFly | (uint)ParcelFlags.AllowLandmark | - (uint)ParcelFlags.AllowAPrimitiveEntry | - (uint)ParcelFlags.AllowDeedToGroup | - (uint)ParcelFlags.CreateObjects | (uint)ParcelFlags.AllowOtherScripts | - (uint)ParcelFlags.AllowVoiceChat; + private uint _flags = (uint) ParcelFlags.AllowFly | (uint) ParcelFlags.AllowLandmark | + (uint) ParcelFlags.AllowAPrimitiveEntry | + (uint) ParcelFlags.AllowDeedToGroup | + (uint) ParcelFlags.CreateObjects | (uint) ParcelFlags.AllowOtherScripts | + (uint) ParcelFlags.SoundLocal | (uint) ParcelFlags.AllowVoiceChat; private byte _landingType = 0; private string _name = "Your Parcel"; @@ -97,36 +97,16 @@ namespace OpenSim.Framework private bool _mediaLoop = false; private bool _obscureMusic = false; private bool _obscureMedia = false; - private float _dwell = 0; - - /// - /// Traffic count of parcel - /// - [XmlIgnore] - public float Dwell - { - get - { - return _dwell; - } - set - { - _dwell = value; - } - } /// /// Whether to obscure parcel media URL /// [XmlIgnore] - public bool ObscureMedia - { - get - { + public bool ObscureMedia { + get { return _obscureMedia; } - set - { + set { _obscureMedia = value; } } @@ -135,14 +115,11 @@ namespace OpenSim.Framework /// Whether to obscure parcel music URL /// [XmlIgnore] - public bool ObscureMusic - { - get - { + public bool ObscureMusic { + get { return _obscureMusic; } - set - { + set { _obscureMusic = value; } } @@ -151,14 +128,11 @@ namespace OpenSim.Framework /// Whether to loop parcel media /// [XmlIgnore] - public bool MediaLoop - { - get - { + public bool MediaLoop { + get { return _mediaLoop; } - set - { + set { _mediaLoop = value; } } @@ -167,14 +141,11 @@ namespace OpenSim.Framework /// Height of parcel media render /// [XmlIgnore] - public int MediaHeight - { - get - { + public int MediaHeight { + get { return _mediaHeight; } - set - { + set { _mediaHeight = value; } } @@ -183,14 +154,11 @@ namespace OpenSim.Framework /// Width of parcel media render /// [XmlIgnore] - public int MediaWidth - { - get - { + public int MediaWidth { + get { return _mediaWidth; } - set - { + set { _mediaWidth = value; } } @@ -199,14 +167,11 @@ namespace OpenSim.Framework /// Upper corner of the AABB for the parcel /// [XmlIgnore] - public Vector3 AABBMax - { - get - { + public Vector3 AABBMax { + get { return _AABBMax; } - set - { + set { _AABBMax = value; } } @@ -214,14 +179,11 @@ namespace OpenSim.Framework /// Lower corner of the AABB for the parcel /// [XmlIgnore] - public Vector3 AABBMin - { - get - { + public Vector3 AABBMin { + get { return _AABBMin; } - set - { + set { _AABBMin = value; } } @@ -229,14 +191,11 @@ namespace OpenSim.Framework /// /// Area in meters^2 the parcel contains /// - public int Area - { - get - { + public int Area { + get { return _area; } - set - { + set { _area = value; } } @@ -244,14 +203,11 @@ namespace OpenSim.Framework /// /// ID of auction (3rd Party Integration) when parcel is being auctioned /// - public uint AuctionID - { - get - { + public uint AuctionID { + get { return _auctionID; } - set - { + set { _auctionID = value; } } @@ -259,14 +215,11 @@ namespace OpenSim.Framework /// /// UUID of authorized buyer of parcel. This is UUID.Zero if anyone can buy it. /// - public UUID AuthBuyerID - { - get - { + public UUID AuthBuyerID { + get { return _authBuyerID; } - set - { + set { _authBuyerID = value; } } @@ -274,14 +227,11 @@ namespace OpenSim.Framework /// /// Category of parcel. Used for classifying the parcel in classified listings /// - public ParcelCategory Category - { - get - { + public ParcelCategory Category { + get { return _category; } - set - { + set { _category = value; } } @@ -289,14 +239,11 @@ namespace OpenSim.Framework /// /// Date that the current owner purchased or claimed the parcel /// - public int ClaimDate - { - get - { + public int ClaimDate { + get { return _claimDate; } - set - { + set { _claimDate = value; } } @@ -304,14 +251,11 @@ namespace OpenSim.Framework /// /// The last price that the parcel was sold at /// - public int ClaimPrice - { - get - { + public int ClaimPrice { + get { return _claimPrice; } - set - { + set { _claimPrice = value; } } @@ -319,14 +263,11 @@ namespace OpenSim.Framework /// /// Global ID for the parcel. (3rd Party Integration) /// - public UUID GlobalID - { - get - { + public UUID GlobalID { + get { return _globalID; } - set - { + set { _globalID = value; } } @@ -334,14 +275,11 @@ namespace OpenSim.Framework /// /// Unique ID of the Group that owns /// - public UUID GroupID - { - get - { + public UUID GroupID { + get { return _groupID; } - set - { + set { _groupID = value; } } @@ -349,14 +287,11 @@ namespace OpenSim.Framework /// /// Returns true if the Land Parcel is owned by a group /// - public bool IsGroupOwned - { - get - { + public bool IsGroupOwned { + get { return _isGroupOwned; } - set - { + set { _isGroupOwned = value; } } @@ -364,14 +299,11 @@ namespace OpenSim.Framework /// /// jp2 data for the image representative of the parcel in the parcel dialog /// - public byte[] Bitmap - { - get - { + public byte[] Bitmap { + get { return _bitmap; } - set - { + set { _bitmap = value; } } @@ -379,14 +311,11 @@ namespace OpenSim.Framework /// /// Parcel Description /// - public string Description - { - get - { + public string Description { + get { return _description; } - set - { + set { _description = value; } } @@ -394,14 +323,11 @@ namespace OpenSim.Framework /// /// Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags /// - public uint Flags - { - get - { + public uint Flags { + get { return _flags; } - set - { + set { _flags = value; } } @@ -410,14 +336,11 @@ namespace OpenSim.Framework /// Determines if people are able to teleport where they please on the parcel or if they /// get constrainted to a specific point on teleport within the parcel /// - public byte LandingType - { - get - { + public byte LandingType { + get { return _landingType; } - set - { + set { _landingType = value; } } @@ -425,14 +348,11 @@ namespace OpenSim.Framework /// /// Parcel Name /// - public string Name - { - get - { + public string Name { + get { return _name; } - set - { + set { _name = value; } } @@ -440,14 +360,11 @@ namespace OpenSim.Framework /// /// Status of Parcel, Leased, Abandoned, For Sale /// - public ParcelStatus Status - { - get - { + public ParcelStatus Status { + get { return _status; } - set - { + set { _status = value; } } @@ -455,14 +372,11 @@ namespace OpenSim.Framework /// /// Internal ID of the parcel. Sometimes the client will try to use this value /// - public int LocalID - { - get - { + public int LocalID { + get { return _localID; } - set - { + set { _localID = value; } } @@ -470,14 +384,11 @@ namespace OpenSim.Framework /// /// Determines if we scale the media based on the surface it's on /// - public byte MediaAutoScale - { - get - { + public byte MediaAutoScale { + get { return _mediaAutoScale; } - set - { + set { _mediaAutoScale = value; } } @@ -485,14 +396,11 @@ namespace OpenSim.Framework /// /// Texture Guid to replace with the output of the media stream /// - public UUID MediaID - { - get - { + public UUID MediaID { + get { return _mediaID; } - set - { + set { _mediaID = value; } } @@ -500,14 +408,11 @@ namespace OpenSim.Framework /// /// URL to the media file to display /// - public string MediaURL - { - get - { + public string MediaURL { + get { return _mediaURL; } - set - { + set { _mediaURL = value; } } @@ -527,14 +432,11 @@ namespace OpenSim.Framework /// /// URL to the shoutcast music stream to play on the parcel /// - public string MusicURL - { - get - { + public string MusicURL { + get { return _musicURL; } - set - { + set { _musicURL = value; } } @@ -543,14 +445,11 @@ namespace OpenSim.Framework /// Owner Avatar or Group of the parcel. Naturally, all land masses must be /// owned by someone /// - public UUID OwnerID - { - get - { + public UUID OwnerID { + get { return _ownerID; } - set - { + set { _ownerID = value; } } @@ -558,14 +457,11 @@ namespace OpenSim.Framework /// /// List of access data for the parcel. User data, some bitflags, and a time /// - public List ParcelAccessList - { - get - { + public List ParcelAccessList { + get { return _parcelAccessList; } - set - { + set { _parcelAccessList = value; } } @@ -573,14 +469,11 @@ namespace OpenSim.Framework /// /// How long in hours a Pass to the parcel is given /// - public float PassHours - { - get - { + public float PassHours { + get { return _passHours; } - set - { + set { _passHours = value; } } @@ -588,14 +481,11 @@ namespace OpenSim.Framework /// /// Price to purchase a Pass to a restricted parcel /// - public int PassPrice - { - get - { + public int PassPrice { + get { return _passPrice; } - set - { + set { _passPrice = value; } } @@ -603,14 +493,11 @@ namespace OpenSim.Framework /// /// When the parcel is being sold, this is the price to purchase the parcel /// - public int SalePrice - { - get - { + public int SalePrice { + get { return _salePrice; } - set - { + set { _salePrice = value; } } @@ -619,14 +506,11 @@ namespace OpenSim.Framework /// Number of meters^2 in the Simulator /// [XmlIgnore] - public int SimwideArea - { - get - { + public int SimwideArea { + get { return _simwideArea; } - set - { + set { _simwideArea = value; } } @@ -635,14 +519,11 @@ namespace OpenSim.Framework /// Number of SceneObjectPart in the Simulator /// [XmlIgnore] - public int SimwidePrims - { - get - { + public int SimwidePrims { + get { return _simwidePrims; } - set - { + set { _simwidePrims = value; } } @@ -650,14 +531,11 @@ namespace OpenSim.Framework /// /// ID of the snapshot used in the client parcel dialog of the parcel /// - public UUID SnapshotID - { - get - { + public UUID SnapshotID { + get { return _snapshotID; } - set - { + set { _snapshotID = value; } } @@ -666,14 +544,11 @@ namespace OpenSim.Framework /// When teleporting is restricted to a certain point, this is the location /// that the user will be redirected to /// - public Vector3 UserLocation - { - get - { + public Vector3 UserLocation { + get { return _userLocation; } - set - { + set { _userLocation = value; } } @@ -682,14 +557,11 @@ namespace OpenSim.Framework /// When teleporting is restricted to a certain point, this is the rotation /// that the user will be positioned /// - public Vector3 UserLookAt - { - get - { + public Vector3 UserLookAt { + get { return _userLookAt; } - set - { + set { _userLookAt = value; } } @@ -698,14 +570,11 @@ namespace OpenSim.Framework /// Autoreturn number of minutes to return SceneObjectGroup that are owned by someone who doesn't own /// the parcel and isn't set to the same 'group' as the parcel. /// - public int OtherCleanTime - { - get - { + public int OtherCleanTime { + get { return _otherCleanTime; } - set - { + set { _otherCleanTime = value; } } @@ -713,14 +582,11 @@ namespace OpenSim.Framework /// /// parcel media description /// - public string MediaDescription - { - get - { + public string MediaDescription { + get { return _mediaDescription; } - set - { + set { _mediaDescription = value; } } @@ -756,7 +622,7 @@ namespace OpenSim.Framework landData._mediaURL = _mediaURL; landData._musicURL = _musicURL; landData._ownerID = _ownerID; - landData._bitmap = (byte[])_bitmap.Clone(); + landData._bitmap = (byte[]) _bitmap.Clone(); landData._description = _description; landData._flags = _flags; landData._name = _name; @@ -777,7 +643,6 @@ namespace OpenSim.Framework landData._obscureMedia = _obscureMedia; landData._simwideArea = _simwideArea; landData._simwidePrims = _simwidePrims; - landData._dwell = _dwell; landData._parcelAccessList.Clear(); foreach (LandAccessEntry entry in _parcelAccessList) diff --git a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs index 446e3c0..9ee0876 100644 --- a/OpenSim/Framework/Monitoring/BaseStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs @@ -43,32 +43,27 @@ namespace OpenSim.Framework.Monitoring StringBuilder sb = new StringBuilder(Environment.NewLine); sb.Append("MEMORY STATISTICS"); sb.Append(Environment.NewLine); - sb.AppendFormat( + sb.Append( + string.Format( "Allocated to OpenSim objects: {0} MB\n", - Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); - - sb.AppendFormat( - "OpenSim last object memory churn : {0} MB/s\n", - Math.Round((MemoryWatchdog.LastMemoryChurn * 1000) / 1024.0 / 1024, 3)); - - sb.AppendFormat( - "OpenSim average object memory churn : {0} MB/s\n", - Math.Round((MemoryWatchdog.AverageMemoryChurn * 1000) / 1024.0 / 1024, 3)); + Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0))); Process myprocess = Process.GetCurrentProcess(); if (!myprocess.HasExited) { myprocess.Refresh(); - sb.AppendFormat( + sb.Append( + string.Format( "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0), Math.Round(Process.GetCurrentProcess().PagedMemorySize64 / 1024.0 / 1024.0), - Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0)); - sb.AppendFormat( + Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0))); + sb.Append( + string.Format( "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n", Math.Round(Process.GetCurrentProcess().PeakWorkingSet64 / 1024.0 / 1024.0), Math.Round(Process.GetCurrentProcess().PeakPagedMemorySize64 / 1024.0 / 1024.0), - Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0)); + Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0))); } else sb.Append("Process reported as Exited \n"); diff --git a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs index c6010cd..a23cf1f 100644 --- a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs +++ b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs @@ -60,7 +60,7 @@ namespace OpenSim.Framework.Monitoring private static bool m_enabled; /// - /// Last memory churn in bytes per millisecond. + /// Average memory churn in bytes per millisecond. /// public static double AverageMemoryChurn { @@ -68,14 +68,6 @@ namespace OpenSim.Framework.Monitoring } /// - /// Average memory churn in bytes per millisecond. - /// - public static double LastMemoryChurn - { - get { if (m_samples.Count > 0) return m_samples.Last(); else return 0; } - } - - /// /// Maximum number of statistical samples. /// /// diff --git a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs index aa86202..cdd7cc7 100644 --- a/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs @@ -355,25 +355,10 @@ Asset service request failures: {3}" + Environment.NewLine, sb.Append(Environment.NewLine); sb.Append( string.Format( - "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}\n\n", + "{0,6:0} {1,6:0} {2,6:0} {3,6:0} {4,6:0} {5,6:0.0} {6,6:0.0} {7,6:0.0} {8,6:0.0} {9,6:0.0} {10,6:0.0}", inPacketsPerSecond, outPacketsPerSecond, pendingDownloads, pendingUploads, unackedBytes, totalFrameTime, netFrameTime, physicsFrameTime, otherFrameTime, agentFrameTime, imageFrameTime)); - - Dictionary> sceneStats; - - if (StatsManager.TryGetStats("scene", out sceneStats)) - { - foreach (KeyValuePair> kvp in sceneStats) - { - foreach (Stat stat in kvp.Value.Values) - { - if (stat.Verbosity == StatVerbosity.Info) - { - sb.AppendFormat("{0} ({1}): {2}{3}\n", stat.Name, stat.Container, stat.Value, stat.UnitName); - } - } - } - } + sb.Append(Environment.NewLine); /* sb.Append(Environment.NewLine); diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 4844336..d78fa6a 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs @@ -25,9 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Collections.Generic; - namespace OpenSim.Framework.Monitoring { /// @@ -35,24 +32,6 @@ namespace OpenSim.Framework.Monitoring /// public class StatsManager { - // Subcommand used to list other stats. - public const string AllSubCommand = "all"; - - // Subcommand used to list other stats. - public const string ListSubCommand = "list"; - - // All subcommands - public static HashSet SubCommands = new HashSet { AllSubCommand, ListSubCommand }; - - /// - /// Registered stats categorized by category/container/shortname - /// - /// - /// Do not add or remove directly from this dictionary. - /// - public static Dictionary>> RegisteredStats - = new Dictionary>>(); - private static AssetStatsCollector assetStats; private static UserStatsCollector userStats; private static SimExtraStatsCollector simExtraStats = new SimExtraStatsCollector(); @@ -61,75 +40,6 @@ namespace OpenSim.Framework.Monitoring public static UserStatsCollector UserStats { get { return userStats; } } public static SimExtraStatsCollector SimExtraStats { get { return simExtraStats; } } - public static void RegisterConsoleCommands(ICommandConsole console) - { - console.Commands.AddCommand( - "General", - false, - "show stats", - "show stats [list|all|]", - "Show statistical information for this server", - "If no final argument is specified then legacy statistics information is currently shown.\n" - + "If list is specified then statistic categories are shown.\n" - + "If all is specified then all registered statistics are shown.\n" - + "If a category name is specified then only statistics from that category are shown.\n" - + "THIS STATS FACILITY IS EXPERIMENTAL AND DOES NOT YET CONTAIN ALL STATS", - HandleShowStatsCommand); - } - - public static void HandleShowStatsCommand(string module, string[] cmd) - { - ICommandConsole con = MainConsole.Instance; - - if (cmd.Length > 2) - { - var categoryName = cmd[2]; - - if (categoryName == AllSubCommand) - { - foreach (var category in RegisteredStats.Values) - { - OutputCategoryStatsToConsole(con, category); - } - } - else if (categoryName == ListSubCommand) - { - con.Output("Statistic categories available are:"); - foreach (string category in RegisteredStats.Keys) - con.OutputFormat(" {0}", category); - } - else - { - Dictionary> category; - if (!RegisteredStats.TryGetValue(categoryName, out category)) - { - con.OutputFormat("No such category as {0}", categoryName); - } - else - { - OutputCategoryStatsToConsole(con, category); - } - } - } - else - { - // Legacy - con.Output(SimExtraStats.Report()); - } - } - - private static void OutputCategoryStatsToConsole( - ICommandConsole con, Dictionary> category) - { - foreach (var container in category.Values) - { - foreach (Stat stat in container.Values) - { - con.Output(stat.ToConsoleString()); - } - } - } - /// /// Start collecting statistics related to assets. /// Should only be called once. @@ -151,275 +61,5 @@ namespace OpenSim.Framework.Monitoring return userStats; } - - /// - /// Registers a statistic. - /// - /// - /// - public static bool RegisterStat(Stat stat) - { - Dictionary> category = null, newCategory; - Dictionary container = null, newContainer; - - lock (RegisteredStats) - { - // Stat name is not unique across category/container/shortname key. - // XXX: For now just return false. This is to avoid problems in regression tests where all tests - // in a class are run in the same instance of the VM. - if (TryGetStat(stat, out category, out container)) - return false; - - // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. - // This means that we don't need to lock or copy them on iteration, which will be a much more - // common operation after startup. - if (container != null) - newContainer = new Dictionary(container); - else - newContainer = new Dictionary(); - - if (category != null) - newCategory = new Dictionary>(category); - else - newCategory = new Dictionary>(); - - newContainer[stat.ShortName] = stat; - newCategory[stat.Container] = newContainer; - RegisteredStats[stat.Category] = newCategory; - } - - return true; - } - - /// - /// Deregister a statistic - /// > - /// - /// > category = null, newCategory; - Dictionary container = null, newContainer; - - lock (RegisteredStats) - { - if (!TryGetStat(stat, out category, out container)) - return false; - - newContainer = new Dictionary(container); - newContainer.Remove(stat.ShortName); - - newCategory = new Dictionary>(category); - newCategory.Remove(stat.Container); - - newCategory[stat.Container] = newContainer; - RegisteredStats[stat.Category] = newCategory; - - return true; - } - } - - public static bool TryGetStats(string category, out Dictionary> stats) - { - return RegisteredStats.TryGetValue(category, out stats); - } - - public static bool TryGetStat( - Stat stat, - out Dictionary> category, - out Dictionary container) - { - category = null; - container = null; - - lock (RegisteredStats) - { - if (RegisteredStats.TryGetValue(stat.Category, out category)) - { - if (category.TryGetValue(stat.Container, out container)) - { - if (container.ContainsKey(stat.ShortName)) - return true; - } - } - } - - return false; - } - } - - /// - /// Stat type. - /// - /// - /// A push stat is one which is continually updated and so it's value can simply by read. - /// A pull stat is one where reading the value triggers a collection method - the stat is not continually updated. - /// - public enum StatType - { - Push, - Pull - } - - /// - /// Verbosity of stat. - /// - /// - /// Info will always be displayed. - /// - public enum StatVerbosity - { - Debug, - Info - } - - /// - /// Holds individual static details - /// - public class Stat - { - /// - /// Category of this stat (e.g. cache, scene, etc). - /// - public string Category { get; private set; } - - /// - /// Containing name for this stat. - /// FIXME: In the case of a scene, this is currently the scene name (though this leaves - /// us with a to-be-resolved problem of non-unique region names). - /// - /// - /// The container. - /// - public string Container { get; private set; } - - public StatType StatType { get; private set; } - - /// - /// Action used to update this stat when the value is requested if it's a pull type. - /// - public Action PullAction { get; private set; } - - public StatVerbosity Verbosity { get; private set; } - public string ShortName { get; private set; } - public string Name { get; private set; } - public string Description { get; private set; } - public virtual string UnitName { get; private set; } - - public virtual double Value - { - get - { - // Asking for an update here means that the updater cannot access this value without infinite recursion. - // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being - // called by the pull action and just return the value. - if (StatType == StatType.Pull) - PullAction(this); - - return m_value; - } - - set - { - m_value = value; - } - } - - private double m_value; - - /// - /// Constructor - /// - /// Short name for the stat. Must not contain spaces. e.g. "LongFrames" - /// Human readable name for the stat. e.g. "Long frames" - /// Description of stat - /// - /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. - /// e.g. " frames" - /// - /// Category under which this stat should appear, e.g. "scene". Do not capitalize. - /// Entity to which this stat relates. e.g. scene name if this is a per scene stat. - /// Push or pull - /// Pull stats need an action to update the stat on request. Push stats should set null here. - /// Verbosity of stat. Controls whether it will appear in short stat display or only full display. - public Stat( - string shortName, - string name, - string description, - string unitName, - string category, - string container, - StatType type, - Action pullAction, - StatVerbosity verbosity) - { - if (StatsManager.SubCommands.Contains(category)) - throw new Exception( - string.Format("Stat cannot be in category '{0}' since this is reserved for a subcommand", category)); - - ShortName = shortName; - Name = name; - Description = description; - UnitName = unitName; - Category = category; - Container = container; - StatType = type; - - if (StatType == StatType.Push && pullAction != null) - throw new Exception("A push stat cannot have a pull action"); - else - PullAction = pullAction; - - Verbosity = verbosity; - } - - public virtual string ToConsoleString() - { - return string.Format( - "{0}.{1}.{2} : {3}{4}", Category, Container, ShortName, Value, UnitName); - } - } - - public class PercentageStat : Stat - { - public int Antecedent { get; set; } - public int Consequent { get; set; } - - public override double Value - { - get - { - int c = Consequent; - - // Avoid any chance of a multi-threaded divide-by-zero - if (c == 0) - return 0; - - return (double)Antecedent / c * 100; - } - - set - { - throw new Exception("Cannot set value on a PercentageStat"); - } - } - - public PercentageStat( - string shortName, - string name, - string description, - string category, - string container, - StatType type, - Action pullAction, - StatVerbosity verbosity) - : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {} - - public override string ToConsoleString() - { - return string.Format( - "{0}.{1}.{2} : {3:0.##}{4} ({5}/{6})", - Category, Container, ShortName, Value, UnitName, Antecedent, Consequent); - } } } \ No newline at end of file diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index 28d6d5c..b709baa 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -89,17 +89,6 @@ namespace OpenSim.Framework.Monitoring FirstTick = Environment.TickCount & Int32.MaxValue; LastTick = FirstTick; } - - public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi) - { - Thread = previousTwi.Thread; - FirstTick = previousTwi.FirstTick; - LastTick = previousTwi.LastTick; - Timeout = previousTwi.Timeout; - IsTimedOut = previousTwi.IsTimedOut; - AlarmIfTimeout = previousTwi.AlarmIfTimeout; - AlarmMethod = previousTwi.AlarmMethod; - } } /// @@ -231,25 +220,7 @@ namespace OpenSim.Framework.Monitoring private static bool RemoveThread(int threadID) { lock (m_threads) - { - ThreadWatchdogInfo twi; - if (m_threads.TryGetValue(threadID, out twi)) - { - m_log.DebugFormat( - "[WATCHDOG]: Removing thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId); - - m_threads.Remove(threadID); - - return true; - } - else - { - m_log.WarnFormat( - "[WATCHDOG]: Requested to remove thread with ID {0} but this is not being monitored", threadID); - - return false; - } - } + return m_threads.Remove(threadID); } public static bool AbortThread(int threadID) @@ -364,9 +335,7 @@ namespace OpenSim.Framework.Monitoring if (callbackInfos == null) callbackInfos = new List(); - // Send a copy of the watchdog info to prevent race conditions where the watchdog - // thread updates the monitoring info after an alarm has been sent out. - callbackInfos.Add(new ThreadWatchdogInfo(threadInfo)); + callbackInfos.Add(threadInfo); } } } diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Framework/PacketPool.cs new file mode 100644 index 0000000..41d17c5 --- /dev/null +++ b/OpenSim/Framework/PacketPool.cs @@ -0,0 +1,247 @@ +/* + * 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.Reflection; +using OpenMetaverse; +using OpenMetaverse.Packets; +using log4net; + +namespace OpenSim.Framework +{ + + public sealed class PacketPool + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static readonly PacketPool instance = new PacketPool(); + + private bool packetPoolEnabled = true; + private bool dataBlockPoolEnabled = true; + + private readonly Dictionary> pool = new Dictionary>(); + + private static Dictionary> DataBlocks = + new Dictionary>(); + + static PacketPool() + { + } + + public static PacketPool Instance + { + get { return instance; } + } + + public bool RecyclePackets + { + set { packetPoolEnabled = value; } + get { return packetPoolEnabled; } + } + + public bool RecycleDataBlocks + { + set { dataBlockPoolEnabled = value; } + get { return dataBlockPoolEnabled; } + } + + public Packet GetPacket(PacketType type) + { + Packet packet; + + if (!packetPoolEnabled) + return Packet.BuildPacket(type); + + lock (pool) + { + if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0) + { + // Creating a new packet if we cannot reuse an old package + packet = Packet.BuildPacket(type); + } + else + { + // Recycle old packages + packet = (pool[type]).Pop(); + } + } + + return packet; + } + + // private byte[] decoded_header = new byte[10]; + private static PacketType GetType(byte[] bytes) + { + byte[] decoded_header = new byte[10 + 8]; + ushort id; + PacketFrequency freq; + + if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0) + { + Helpers.ZeroDecode(bytes, 16, decoded_header); + } + else + { + Buffer.BlockCopy(bytes, 0, decoded_header, 0, 10); + } + + if (decoded_header[6] == 0xFF) + { + if (decoded_header[7] == 0xFF) + { + id = (ushort) ((decoded_header[8] << 8) + decoded_header[9]); + freq = PacketFrequency.Low; + } + else + { + id = decoded_header[7]; + freq = PacketFrequency.Medium; + } + } + else + { + id = decoded_header[6]; + freq = PacketFrequency.High; + } + + return Packet.GetType(id, freq); + } + + public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer) + { + PacketType type = GetType(bytes); + + Array.Clear(zeroBuffer, 0, zeroBuffer.Length); + + int i = 0; + Packet packet = GetPacket(type); + if (packet == null) + m_log.WarnFormat("[PACKETPOOL]: Failed to get packet of type {0}", type); + else + packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); + + return packet; + } + + /// + /// Return a packet to the packet pool + /// + /// + public void ReturnPacket(Packet packet) + { + if (dataBlockPoolEnabled) + { + switch (packet.Type) + { + case PacketType.ObjectUpdate: + ObjectUpdatePacket oup = (ObjectUpdatePacket)packet; + + foreach (ObjectUpdatePacket.ObjectDataBlock oupod in oup.ObjectData) + ReturnDataBlock(oupod); + + oup.ObjectData = null; + break; + + case PacketType.ImprovedTerseObjectUpdate: + ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet; + + foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock itoupod in itoup.ObjectData) + ReturnDataBlock(itoupod); + + itoup.ObjectData = null; + break; + } + } + + if (packetPoolEnabled) + { + switch (packet.Type) + { + // List pooling packets here + case PacketType.PacketAck: + case PacketType.ObjectUpdate: + case PacketType.ImprovedTerseObjectUpdate: + lock (pool) + { + PacketType type = packet.Type; + + if (!pool.ContainsKey(type)) + { + pool[type] = new Stack(); + } + + if ((pool[type]).Count < 50) + { + (pool[type]).Push(packet); + } + } + break; + + // Other packets wont pool + default: + return; + } + } + } + + public static T GetDataBlock() where T: new() + { + lock (DataBlocks) + { + Stack s; + + if (DataBlocks.TryGetValue(typeof(T), out s)) + { + if (s.Count > 0) + return (T)s.Pop(); + } + else + { + DataBlocks[typeof(T)] = new Stack(); + } + + return new T(); + } + } + + public static void ReturnDataBlock(T block) where T: new() + { + if (block == null) + return; + + lock (DataBlocks) + { + if (!DataBlocks.ContainsKey(typeof(T))) + DataBlocks[typeof(T)] = new Stack(); + + if (DataBlocks[typeof(T)].Count < 50) + DataBlocks[typeof(T)].Push(block); + } + } + } +} diff --git a/OpenSim/Framework/Pool.cs b/OpenSim/Framework/Pool.cs deleted file mode 100644 index 5484f5c..0000000 --- a/OpenSim/Framework/Pool.cs +++ /dev/null @@ -1,91 +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.Generic; - -namespace OpenSim.Framework -{ - /// - /// Naive pool implementation. - /// - /// - /// Currently assumes that objects are in a useable state when returned. - /// - public class Pool - { - /// - /// Number of objects in the pool. - /// - public int Count - { - get - { - lock (m_pool) - return m_pool.Count; - } - } - - private Stack m_pool; - - /// - /// Maximum pool size. Beyond this, any returned objects are not pooled. - /// - private int m_maxPoolSize; - - private Func m_createFunction; - - public Pool(Func createFunction, int maxSize) - { - m_maxPoolSize = maxSize; - m_createFunction = createFunction; - m_pool = new Stack(m_maxPoolSize); - } - - public T GetObject() - { - lock (m_pool) - { - if (m_pool.Count > 0) - return m_pool.Pop(); - else - return m_createFunction(); - } - } - - public void ReturnObject(T obj) - { - lock (m_pool) - { - if (m_pool.Count >= m_maxPoolSize) - return; - else - m_pool.Push(obj); - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Framework/RegionFlags.cs b/OpenSim/Framework/RegionFlags.cs deleted file mode 100644 index a3089b0..0000000 --- a/OpenSim/Framework/RegionFlags.cs +++ /dev/null @@ -1,53 +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; - -namespace OpenSim.Framework -{ - /// - /// Region flags used internally by OpenSimulator to store installation specific information about regions. - /// - /// - /// Don't confuse with OpenMetaverse.RegionFlags which are client facing flags (i.e. they go over the wire). - /// Returned by IGridService.GetRegionFlags() - /// - [Flags] - public enum RegionFlags : int - { - DefaultRegion = 1, // Used for new Rez. Random if multiple defined - FallbackRegion = 2, // Regions we redirect to when the destination is down - RegionOnline = 4, // Set when a region comes online, unset when it unregisters and DeleteOnUnregister is false - NoDirectLogin = 8, // Region unavailable for direct logins (by name) - Persistent = 16, // Don't remove on unregister - LockedOut = 32, // Don't allow registration - NoMove = 64, // Don't allow moving this region - Reservation = 128, // This is an inactive reservation - Authenticate = 256, // Require authentication - Hyperlink = 512 // Record represents a HG link - } -} \ No newline at end of file diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index e7bed6a..4bde7be 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -122,13 +122,10 @@ namespace OpenSim.Framework public UUID lastMapUUID = UUID.Zero; public string lastMapRefresh = "0"; - private float m_nonphysPrimMin = 0; private int m_nonphysPrimMax = 0; - private float m_physPrimMin = 0; private int m_physPrimMax = 0; private bool m_clampPrimSize = false; private int m_objectCapacity = 0; - private int m_linksetCapacity = 0; private int m_agentCapacity = 0; private string m_regionType = String.Empty; private RegionLightShareData m_windlight = new RegionLightShareData(); @@ -290,21 +287,11 @@ namespace OpenSim.Framework set { m_windlight = value; } } - public float NonphysPrimMin - { - get { return m_nonphysPrimMin; } - } - public int NonphysPrimMax { get { return m_nonphysPrimMax; } } - public float PhysPrimMin - { - get { return m_physPrimMin; } - } - public int PhysPrimMax { get { return m_physPrimMax; } @@ -320,11 +307,6 @@ namespace OpenSim.Framework get { return m_objectCapacity; } } - public int LinksetCapacity - { - get { return m_linksetCapacity; } - } - public int AgentCapacity { get { return m_agentCapacity; } @@ -643,31 +625,16 @@ namespace OpenSim.Framework m_regionType = config.GetString("RegionType", String.Empty); allKeys.Remove("RegionType"); - #region Prim stuff - - m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0); - allKeys.Remove("NonPhysicalPrimMin"); - - m_nonphysPrimMax = config.GetInt("NonPhysicalPrimMax", 0); - allKeys.Remove("NonPhysicalPrimMax"); - - m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0); - allKeys.Remove("PhysicalPrimMin"); - + // Prim stuff + // + m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0); + allKeys.Remove("NonphysicalPrimMax"); m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); allKeys.Remove("PhysicalPrimMax"); - m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); allKeys.Remove("ClampPrimSize"); - m_objectCapacity = config.GetInt("MaxPrims", 15000); allKeys.Remove("MaxPrims"); - - m_linksetCapacity = config.GetInt("LinksetPrims", 0); - allKeys.Remove("LinksetPrims"); - - #endregion - m_agentCapacity = config.GetInt("MaxAgents", 100); allKeys.Remove("MaxAgents"); @@ -706,27 +673,16 @@ namespace OpenSim.Framework config.Set("ExternalHostName", m_externalHostName); - if (m_nonphysPrimMin > 0) - config.Set("NonphysicalPrimMax", m_nonphysPrimMin); - - if (m_nonphysPrimMax > 0) + if (m_nonphysPrimMax != 0) config.Set("NonphysicalPrimMax", m_nonphysPrimMax); - - if (m_physPrimMin > 0) - config.Set("PhysicalPrimMax", m_physPrimMin); - - if (m_physPrimMax > 0) + if (m_physPrimMax != 0) config.Set("PhysicalPrimMax", m_physPrimMax); - config.Set("ClampPrimSize", m_clampPrimSize.ToString()); - if (m_objectCapacity > 0) + if (m_objectCapacity != 0) config.Set("MaxPrims", m_objectCapacity); - if (m_linksetCapacity > 0) - config.Set("LinksetPrims", m_linksetCapacity); - - if (m_agentCapacity > 0) + if (m_agentCapacity != 0) config.Set("MaxAgents", m_agentCapacity); if (ScopeID != UUID.Zero) @@ -803,15 +759,9 @@ namespace OpenSim.Framework configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); - configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, - "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true); - configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); - configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, - "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true); - configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Maximum size for physical prims", m_physPrimMax.ToString(), true); @@ -821,9 +771,6 @@ namespace OpenSim.Framework configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Max objects this sim will hold", m_objectCapacity.ToString(), true); - configMember.addConfigurationOption("linkset_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, - "Max prims an object will hold", m_linksetCapacity.ToString(), true); - configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Max avatars this sim will hold", m_agentCapacity.ToString(), true); @@ -945,9 +892,6 @@ namespace OpenSim.Framework case "object_capacity": m_objectCapacity = (int)configuration_result; break; - case "linkset_capacity": - m_linksetCapacity = (int)configuration_result; - break; case "agent_capacity": m_agentCapacity = (int)configuration_result; break; diff --git a/OpenSim/Framework/Serialization/ArchiveConstants.cs b/OpenSim/Framework/Serialization/ArchiveConstants.cs index 48f1c4f..2c5e001 100644 --- a/OpenSim/Framework/Serialization/ArchiveConstants.cs +++ b/OpenSim/Framework/Serialization/ArchiveConstants.cs @@ -53,11 +53,6 @@ namespace OpenSim.Framework.Serialization public const string INVENTORY_PATH = "inventory/"; /// - /// Path for regions in a multi-region archive - /// - public const string REGIONS_PATH = "regions/"; - - /// /// Path for the prims file /// public const string OBJECTS_PATH = "objects/"; diff --git a/OpenSim/Framework/Serialization/External/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs index fa7160f..d31d27c 100644 --- a/OpenSim/Framework/Serialization/External/OspResolver.cs +++ b/OpenSim/Framework/Serialization/External/OspResolver.cs @@ -65,14 +65,9 @@ namespace OpenSim.Framework.Serialization UserAccount account = userService.GetUserAccount(UUID.Zero, userId); if (account != null) - { return MakeOspa(account.FirstName, account.LastName); - } // else -// { // m_log.WarnFormat("[OSP RESOLVER]: No user account for {0}", userId); -// System.Console.WriteLine("[OSP RESOLVER]: No user account for {0}", userId); -// } return null; } @@ -84,13 +79,10 @@ namespace OpenSim.Framework.Serialization /// public static string MakeOspa(string firstName, string lastName) { - string ospa - = OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; - -// m_log.DebugFormat("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); -// System.Console.WriteLine("[OSP RESOLVER]: Made OSPA {0} for {1} {2}", ospa, firstName, lastName); +// m_log.DebugFormat("[OSP RESOLVER]: Making OSPA for {0} {1}", firstName, lastName); - return ospa; + return + OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; } /// diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 605909d..cf19002 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -96,6 +96,11 @@ namespace OpenSim.Framework.Servers get { return m_httpServer; } } + /// + /// Holds the non-viewer statistics collection object for this service/server + /// + protected IStatsCollector m_stats; + public BaseOpenSimServer() { m_startuptime = DateTime.Now; @@ -172,6 +177,10 @@ namespace OpenSim.Framework.Servers "show info", "Show general information about the server", HandleShow); + m_console.Commands.AddCommand("General", false, "show stats", + "show stats", + "Show statistics", HandleShow); + m_console.Commands.AddCommand("General", false, "show threads", "show threads", "Show thread status", HandleShow); @@ -192,19 +201,8 @@ namespace OpenSim.Framework.Servers "threads show", "Show thread status. Synonym for \"show threads\"", (string module, string[] args) => Notice(GetThreadsReport())); - - m_console.Commands.AddCommand("General", false, "force gc", - "force gc", - "Manually invoke runtime garbage collection. For debugging purposes", - HandleForceGc); } } - - private void HandleForceGc(string module, string[] args) - { - MainConsole.Instance.Output("Manually invoking runtime garbage collection"); - GC.Collect(); - } /// /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing @@ -228,7 +226,12 @@ namespace OpenSim.Framework.Servers { StringBuilder sb = new StringBuilder("DIAGNOSTICS\n\n"); sb.Append(GetUptimeReport()); - sb.Append(StatsManager.SimExtraStats.Report()); + + if (m_stats != null) + { + sb.Append(m_stats.Report()); + } + sb.Append(Environment.NewLine); sb.Append(GetThreadsReport()); @@ -379,6 +382,10 @@ namespace OpenSim.Framework.Servers { Notice("set log level [level] - change the console logging level only. For example, off or debug."); Notice("show info - show server information (e.g. startup path)."); + + if (m_stats != null) + Notice("show stats - show statistical information for this server"); + Notice("show threads - list tracked threads"); Notice("show uptime - show server startup time and uptime."); Notice("show version - show server version."); @@ -402,6 +409,11 @@ namespace OpenSim.Framework.Servers ShowInfo(); break; + case "stats": + if (m_stats != null) + Notice(m_stats.Report()); + break; + case "threads": Notice(GetThreadsReport()); break; @@ -592,7 +604,8 @@ namespace OpenSim.Framework.Servers public string osSecret { // Secret uuid for the simulator - get { return m_osSecret; } + get { return m_osSecret; } + } public string StatReport(IOSHttpRequest httpRequest) @@ -600,11 +613,11 @@ namespace OpenSim.Framework.Servers // If we catch a request for "callback", wrap the response in the value for jsonp if (httpRequest.Query.ContainsKey("callback")) { - return httpRequest.Query["callback"].ToString() + "(" + StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version) + ");"; + return httpRequest.Query["callback"].ToString() + "(" + m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version) + ");"; } else { - return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version); + return m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version); } } diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 3198891..788a0b9 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -54,23 +54,8 @@ namespace OpenSim.Framework.Servers.HttpServer private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); - /// - /// Gets or sets the debug level. - /// - /// - /// See MainServer.DebugLevel. - /// public int DebugLevel { get; set; } - /// - /// Request number for diagnostic purposes. - /// - /// - /// This is an internal number. In some debug situations an external number may also be supplied in the - /// opensim-request-id header but we are not currently logging this. - /// - public int RequestNumber { get; private set; } - private volatile int NotSocketErrors = 0; public volatile bool HTTPDRunning = false; @@ -82,7 +67,7 @@ namespace OpenSim.Framework.Servers.HttpServer protected Dictionary m_llsdHandlers = new Dictionary(); protected Dictionary m_streamHandlers = new Dictionary(); protected Dictionary m_HTTPHandlers = new Dictionary(); -// protected Dictionary m_agentHandlers = new Dictionary(); + protected Dictionary m_agentHandlers = new Dictionary(); protected Dictionary m_pollHandlers = new Dictionary(); @@ -260,29 +245,29 @@ namespace OpenSim.Framework.Servers.HttpServer return new List(m_pollHandlers.Keys); } -// // Note that the agent string is provided simply to differentiate -// // the handlers - it is NOT required to be an actual agent header -// // value. -// public bool AddAgentHandler(string agent, IHttpAgentHandler handler) -// { -// lock (m_agentHandlers) -// { -// if (!m_agentHandlers.ContainsKey(agent)) -// { -// m_agentHandlers.Add(agent, handler); -// return true; -// } -// } -// -// //must already have a handler for that path so return false -// return false; -// } -// -// public List GetAgentHandlerKeys() -// { -// lock (m_agentHandlers) -// return new List(m_agentHandlers.Keys); -// } + // Note that the agent string is provided simply to differentiate + // the handlers - it is NOT required to be an actual agent header + // value. + public bool AddAgentHandler(string agent, IHttpAgentHandler handler) + { + lock (m_agentHandlers) + { + if (!m_agentHandlers.ContainsKey(agent)) + { + m_agentHandlers.Add(agent, handler); + return true; + } + } + + //must already have a handler for that path so return false + return false; + } + + public List GetAgentHandlerKeys() + { + lock (m_agentHandlers) + return new List(m_agentHandlers.Keys); + } public bool AddLLSDHandler(string path, LLSDMethod handler) { @@ -311,8 +296,6 @@ namespace OpenSim.Framework.Servers.HttpServer private void OnRequest(object source, RequestEventArgs args) { - RequestNumber++; - try { IHttpClientContext context = (IHttpClientContext)source; @@ -423,6 +406,7 @@ namespace OpenSim.Framework.Servers.HttpServer string requestMethod = request.HttpMethod; string uriString = request.RawUrl; +// string reqnum = "unknown"; int requestStartTick = Environment.TickCount; // Will be adjusted later on. @@ -439,22 +423,22 @@ namespace OpenSim.Framework.Servers.HttpServer Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); -// // This is the REST agent interface. We require an agent to properly identify -// // itself. If the REST handler recognizes the prefix it will attempt to -// // satisfy the request. If it is not recognizable, and no damage has occurred -// // the request can be passed through to the other handlers. This is a low -// // probability event; if a request is matched it is normally expected to be -// // handled -// IHttpAgentHandler agentHandler; -// -// if (TryGetAgentHandler(request, response, out agentHandler)) -// { -// if (HandleAgentRequest(agentHandler, request, response)) -// { -// requestEndTick = Environment.TickCount; -// return; -// } -// } + // This is the REST agent interface. We require an agent to properly identify + // itself. If the REST handler recognizes the prefix it will attempt to + // satisfy the request. If it is not recognizable, and no damage has occurred + // the request can be passed through to the other handlers. This is a low + // probability event; if a request is matched it is normally expected to be + // handled + IHttpAgentHandler agentHandler; + + if (TryGetAgentHandler(request, response, out agentHandler)) + { + if (HandleAgentRequest(agentHandler, request, response)) + { + requestEndTick = Environment.TickCount; + return; + } + } //response.KeepAlive = true; response.SendChunked = false; @@ -466,7 +450,9 @@ namespace OpenSim.Framework.Servers.HttpServer if (TryGetStreamHandler(handlerKey, out requestHandler)) { if (DebugLevel >= 3) - LogIncomingToStreamHandler(request, requestHandler); + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", + request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. @@ -543,8 +529,11 @@ namespace OpenSim.Framework.Servers.HttpServer { case null: case "text/html": + if (DebugLevel >= 3) - LogIncomingToContentTypeHandler(request); + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); buffer = HandleHTTPRequest(request, response); break; @@ -552,8 +541,11 @@ namespace OpenSim.Framework.Servers.HttpServer case "application/llsd+xml": case "application/xml+llsd": case "application/llsd+json": + if (DebugLevel >= 3) - LogIncomingToContentTypeHandler(request); + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); buffer = HandleLLSDRequests(request, response); break; @@ -572,7 +564,9 @@ namespace OpenSim.Framework.Servers.HttpServer if (DoWeHaveALLSDHandler(request.RawUrl)) { if (DebugLevel >= 3) - LogIncomingToContentTypeHandler(request); + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); buffer = HandleLLSDRequests(request, response); } @@ -580,14 +574,18 @@ namespace OpenSim.Framework.Servers.HttpServer else if (DoWeHaveAHTTPHandler(request.RawUrl)) { if (DebugLevel >= 3) - LogIncomingToContentTypeHandler(request); + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); buffer = HandleHTTPRequest(request, response); } else { if (DebugLevel >= 3) - LogIncomingToXmlRpcHandler(request); + m_log.DebugFormat( + "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", + request.HttpMethod, request.Url.PathAndQuery); // generic login request. buffer = HandleXmlRpcRequests(request, response); @@ -631,11 +629,11 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (IOException e) { - m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e); + m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); } catch (Exception e) { - m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e); + m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); SendHTML500(response); } finally @@ -646,93 +644,17 @@ namespace OpenSim.Framework.Servers.HttpServer if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) { m_log.InfoFormat( - "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", - RequestNumber, + "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", requestMethod, uriString, requestHandler != null ? requestHandler.Name : "", requestHandler != null ? requestHandler.Description : "", - request.RemoteIPEndPoint, - tickdiff); - } - else if (DebugLevel >= 4) - { - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} took {2}ms", - RequestNumber, - Port, + request.RemoteIPEndPoint.ToString(), tickdiff); } } } - private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) - { - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} stream handler {2} {3} {4} {5} from {6}", - RequestNumber, - Port, - request.HttpMethod, - request.Url.PathAndQuery, - requestHandler.Name, - requestHandler.Description, - request.RemoteIPEndPoint); - - if (DebugLevel >= 5) - LogIncomingInDetail(request); - } - - private void LogIncomingToContentTypeHandler(OSHttpRequest request) - { - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", - RequestNumber, - Port, - (request.ContentType == null || request.ContentType == "") ? "not set" : request.ContentType, - request.HttpMethod, - request.Url.PathAndQuery, - request.RemoteIPEndPoint); - - if (DebugLevel >= 5) - LogIncomingInDetail(request); - } - - private void LogIncomingToXmlRpcHandler(OSHttpRequest request) - { - m_log.DebugFormat( - "[BASE HTTP SERVER]: HTTP IN {0} :{1} assumed generic XMLRPC request {2} {3} from {4}", - RequestNumber, - Port, - request.HttpMethod, - request.Url.PathAndQuery, - request.RemoteIPEndPoint); - - if (DebugLevel >= 5) - LogIncomingInDetail(request); - } - - private void LogIncomingInDetail(OSHttpRequest request) - { - using (StreamReader reader = new StreamReader(Util.Copy(request.InputStream), Encoding.UTF8)) - { - string output; - - if (DebugLevel == 5) - { - const int sampleLength = 80; - char[] sampleChars = new char[sampleLength]; - reader.Read(sampleChars, 0, sampleLength); - output = new string(sampleChars); - } - else - { - output = reader.ReadToEnd(); - } - - m_log.DebugFormat("[BASE HTTP SERVER]: {0}...", output.Replace("\n", @"\n")); - } - } - private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) { string bestMatch = null; @@ -825,24 +747,24 @@ namespace OpenSim.Framework.Servers.HttpServer } } -// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) -// { -// agentHandler = null; -// -// lock (m_agentHandlers) -// { -// foreach (IHttpAgentHandler handler in m_agentHandlers.Values) -// { -// if (handler.Match(request, response)) -// { -// agentHandler = handler; -// return true; -// } -// } -// } -// -// return false; -// } + private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) + { + agentHandler = null; + + lock (m_agentHandlers) + { + foreach (IHttpAgentHandler handler in m_agentHandlers.Values) + { + if (handler.Match(request, response)) + { + agentHandler = handler; + return true; + } + } + } + + return false; + } /// /// Try all the registered xmlrpc handlers when an xmlrpc request is received. @@ -1815,21 +1737,21 @@ namespace OpenSim.Framework.Servers.HttpServer m_pollHandlers.Remove(path); } -// public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) -// { -// lock (m_agentHandlers) -// { -// IHttpAgentHandler foundHandler; -// -// if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) -// { -// m_agentHandlers.Remove(agent); -// return true; -// } -// } -// -// return false; -// } + public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) + { + lock (m_agentHandlers) + { + IHttpAgentHandler foundHandler; + + if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) + { + m_agentHandlers.Remove(agent); + return true; + } + } + + return false; + } public void RemoveXmlRPCHandler(string method) { diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index 0bd3aae..db58f6f 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs @@ -41,10 +41,10 @@ namespace OpenSim.Framework.Servers.HttpServer uint Port { get; } bool UseSSL { get; } -// // Note that the agent string is provided simply to differentiate -// // the handlers - it is NOT required to be an actual agent header -// // value. -// bool AddAgentHandler(string agent, IHttpAgentHandler handler); + // Note that the agent string is provided simply to differentiate + // the handlers - it is NOT required to be an actual agent header + // value. + bool AddAgentHandler(string agent, IHttpAgentHandler handler); /// /// Add a handler for an HTTP request. @@ -106,13 +106,13 @@ namespace OpenSim.Framework.Servers.HttpServer bool SetDefaultLLSDHandler(DefaultLLSDMethod handler); -// /// -// /// Remove the agent if it is registered. -// /// -// /// -// /// -// /// -// bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); + /// + /// Remove the agent if it is registered. + /// + /// + /// + /// + bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); /// /// Remove an HTTP handler diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index ae7d515..8dc0e3a 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Net; -using System.Text; using log4net; using OpenSim.Framework; using OpenSim.Framework.Console; @@ -48,12 +47,9 @@ namespace OpenSim.Framework.Servers /// Control the printing of certain debug messages. /// /// - /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data. - /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data. - /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged. - /// If DebugLevel >= 4 then the time taken to fulfill the request is logged. - /// If DebugLevel >= 5 then the start of the body of incoming non-poll HTTP requests will be logged. - /// If DebugLevel >= 6 then the entire body of incoming non-poll HTTP requests will be logged. + /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data. + /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data. + /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged. /// public static int DebugLevel { @@ -105,28 +101,17 @@ namespace OpenSim.Framework.Servers get { return new Dictionary(m_Servers); } } + public static void RegisterHttpConsoleCommands(ICommandConsole console) { console.Commands.AddCommand( - "Comms", false, "show http-handlers", - "show http-handlers", - "Show all registered http handlers", HandleShowHttpHandlersCommand); - - console.Commands.AddCommand( - "Debug", false, "debug http", "debug http []", - "Turn on http request logging.", - "If in or all and\n" - + " level <= 0 then no extra logging is done.\n" - + " level >= 1 then short warnings are logged when receiving bad input data.\n" - + " level >= 2 then long warnings are logged when receiving bad input data.\n" - + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" - + " level >= 4 then the time taken to fulfill the request is logged.\n" - + " level >= 5 then a sample from the beginning of the incoming data is logged.\n" - + " level >= 6 then the entire incoming data is logged.\n" - + " no level is specified then the current level is returned.\n\n" - + "If out or all and\n" - + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" - + " level >= 4 then the time taken to fulfill the request is logged.\n", + "Debug", false, "debug http", "debug http []", + "Turn on inbound non-poll http request debugging.", + "If level <= 0, then no extra logging is done.\n" + + "If level >= 1, then short warnings are logged when receiving bad input data.\n" + + "If level >= 2, then long warnings are logged when receiving bad input data.\n" + + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" + + "If no level is specified then the current level is returned.", HandleDebugHttpCommand); } @@ -134,120 +119,25 @@ namespace OpenSim.Framework.Servers /// Turn on some debugging values for OpenSim. /// /// - private static void HandleDebugHttpCommand(string module, string[] cmdparams) + private static void HandleDebugHttpCommand(string module, string[] args) { - if (cmdparams.Length < 3) - { - MainConsole.Instance.Output("Usage: debug http 0..6"); - return; - } - - bool inReqs = false; - bool outReqs = false; - bool allReqs = false; - - string subCommand = cmdparams[2]; - - if (subCommand.ToLower() == "in") - { - inReqs = true; - } - else if (subCommand.ToLower() == "out") - { - outReqs = true; - } - else if (subCommand.ToLower() == "all") - { - allReqs = true; - } - else + if (args.Length == 3) { - MainConsole.Instance.Output("You must specify in, out or all"); - return; - } - - if (cmdparams.Length >= 4) - { - string rawNewDebug = cmdparams[3]; int newDebug; - - if (!int.TryParse(rawNewDebug, out newDebug)) - { - MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug); - return; - } - - if (newDebug < 0 || newDebug > 6) - { - MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..6", newDebug); - return; - } - - if (allReqs || inReqs) + if (int.TryParse(args[2], out newDebug)) { MainServer.DebugLevel = newDebug; - MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug); - } - - if (allReqs || outReqs) - { - WebUtil.DebugLevel = newDebug; - MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug); + MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); } } - else + else if (args.Length == 2) { - if (allReqs || inReqs) - MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel); - - if (allReqs || outReqs) - MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel); + MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel); } - } - - private static void HandleShowHttpHandlersCommand(string module, string[] args) - { - if (args.Length != 2) - { - MainConsole.Instance.Output("Usage: show http-handlers"); - return; - } - - StringBuilder handlers = new StringBuilder(); - - lock (m_Servers) + else { - foreach (BaseHttpServer httpServer in m_Servers.Values) - { - handlers.AppendFormat( - "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port); - - handlers.AppendFormat("* XMLRPC:\n"); - foreach (String s in httpServer.GetXmlRpcHandlerKeys()) - handlers.AppendFormat("\t{0}\n", s); - - handlers.AppendFormat("* HTTP:\n"); - List poll = httpServer.GetPollServiceHandlerKeys(); - foreach (String s in httpServer.GetHTTPHandlerKeys()) - handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); - -// handlers.AppendFormat("* Agent:\n"); -// foreach (String s in httpServer.GetAgentHandlerKeys()) -// handlers.AppendFormat("\t{0}\n", s); - - handlers.AppendFormat("* LLSD:\n"); - foreach (String s in httpServer.GetLLSDHandlerKeys()) - handlers.AppendFormat("\t{0}\n", s); - - handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count); - foreach (String s in httpServer.GetStreamHandlerKeys()) - handlers.AppendFormat("\t{0}\n", s); - - handlers.Append("\n"); - } + MainConsole.Instance.Output("Usage: debug http 0..3"); } - - MainConsole.Instance.Output(handlers.ToString()); } /// diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index bb094ed..016a174 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -29,7 +29,7 @@ namespace OpenSim { public class VersionInfo { - private const string VERSION_NUMBER = "0.7.5CM"; + private const string VERSION_NUMBER = "0.7.4CM"; private const Flavour VERSION_FLAVOUR = Flavour.Dev; public enum Flavour diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs index 62ecbd1..4d07746 100644 --- a/OpenSim/Framework/TaskInventoryDictionary.cs +++ b/OpenSim/Framework/TaskInventoryDictionary.cs @@ -39,12 +39,10 @@ using OpenMetaverse; namespace OpenSim.Framework { /// - /// A dictionary containing task inventory items. Indexed by item UUID. + /// A dictionary for task inventory. /// - /// /// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before /// iterating over it. - /// public class TaskInventoryDictionary : Dictionary, ICloneable, IXmlSerializable { diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 574ee56..fb818ee 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -73,6 +73,9 @@ namespace OpenSim.Framework private bool _ownerChanged = false; + // This used ONLY during copy. It can't be relied on at other times! + private bool _scriptRunning = true; + public UUID AssetID { get { return _assetID; @@ -350,13 +353,14 @@ namespace OpenSim.Framework } } - /// - /// This used ONLY during copy. It can't be relied on at other times! - /// - /// - /// For true script running status, use IEntityInventory.TryGetScriptInstanceRunning() for now. - /// - public bool ScriptRunning { get; set; } + public bool ScriptRunning { + get { + return _scriptRunning; + } + set { + _scriptRunning = value; + } + } // See ICloneable @@ -384,7 +388,6 @@ namespace OpenSim.Framework public TaskInventoryItem() { - ScriptRunning = true; CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; } } diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index e76a37b..384f716 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -546,19 +546,6 @@ namespace OpenSim.Framework } /// - /// Determines whether a point is inside a bounding box. - /// - /// - /// - /// - /// - public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max) - { - return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z - && v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z; - } - - /// /// Are the co-ordinates of the new region visible from the old region? /// /// Old region x-coord @@ -875,12 +862,6 @@ namespace OpenSim.Framework return Math.Min(Math.Max(x, min), max); } - public static Vector3 Clip(Vector3 vec, float min, float max) - { - return new Vector3(Clip(vec.X, min, max), Clip(vec.Y, min, max), - Clip(vec.Z, min, max)); - } - /// /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. /// @@ -1032,38 +1013,6 @@ namespace OpenSim.Framework } } - /// - /// Copy data from one stream to another, leaving the read position of both streams at the beginning. - /// - /// - /// Input stream. Must be seekable. - /// - /// - /// Thrown if the input stream is not seekable. - /// - public static Stream Copy(Stream inputStream) - { - if (!inputStream.CanSeek) - throw new ArgumentException("Util.Copy(Stream inputStream) must receive an inputStream that can seek"); - - const int readSize = 256; - byte[] buffer = new byte[readSize]; - MemoryStream ms = new MemoryStream(); - - int count = inputStream.Read(buffer, 0, readSize); - - while (count > 0) - { - ms.Write(buffer, 0, count); - count = inputStream.Read(buffer, 0, readSize); - } - - ms.Position = 0; - inputStream.Position = 0; - - return ms; - } - public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) { return SendXmlRpcCommand(url, methodName, args); diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index b85d93d..30a8c28 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -54,17 +54,9 @@ namespace OpenSim.Framework MethodBase.GetCurrentMethod().DeclaringType); /// - /// Control the printing of certain debug messages. - /// - /// - /// If DebugLevel >= 3 then short notices about outgoing HTTP requests are logged. - /// - public static int DebugLevel { get; set; } - - /// /// Request number for diagnostic purposes. /// - public static int RequestNumber { get; internal set; } + public static int RequestNumber = 0; /// /// this is the header field used to communicate the local request id @@ -154,11 +146,7 @@ namespace OpenSim.Framework private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) { int reqnum = RequestNumber++; - - if (DebugLevel >= 3) - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} ServiceOSD {1} {2} (timeout {3}, compressed {4})", - reqnum, method, url, timeout, compressed); + // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); string errorMessage = "unknown error"; int tickstart = Util.EnvironmentTickCount(); @@ -242,7 +230,7 @@ namespace OpenSim.Framework int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); if (tickdiff > LongCallTime) m_log.InfoFormat( - "[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing, {5}", + "[OSD REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", reqnum, method, url, @@ -251,14 +239,10 @@ namespace OpenSim.Framework strBuffer != null ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) : ""); - else if (DebugLevel >= 4) - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", - reqnum, tickdiff, tickdata); } m_log.DebugFormat( - "[WEB UTIL]: ServiceOSD request {0} {1} {2} FAILED: {3}", reqnum, url, method, errorMessage); + "[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage); return ErrorResponseMap(errorMessage); } @@ -334,11 +318,7 @@ namespace OpenSim.Framework { int reqnum = RequestNumber++; string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; - - if (DebugLevel >= 3) - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})", - reqnum, method, url, timeout); + // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); string errorMessage = "unknown error"; int tickstart = Util.EnvironmentTickCount(); @@ -401,7 +381,7 @@ namespace OpenSim.Framework int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); if (tickdiff > LongCallTime) m_log.InfoFormat( - "[WEB UTIL]: Slow ServiceForm request {0} {1} {2} took {3}ms, {4}ms writing, {5}", + "[SERVICE FORM]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", reqnum, method, url, @@ -410,13 +390,9 @@ namespace OpenSim.Framework queryString != null ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString : ""); - else if (DebugLevel >= 4) - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", - reqnum, tickdiff, tickdata); } - m_log.WarnFormat("[WEB UTIL]: ServiceForm request {0} {1} {2} failed: {2}", reqnum, method, url, errorMessage); + m_log.WarnFormat("[SERVICE FORM]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage); return ErrorResponseMap(errorMessage); } @@ -668,6 +644,7 @@ namespace OpenSim.Framework /// public static string[] GetPreferredImageTypes(string accept) { + if (accept == null || accept == string.Empty) return new string[0]; @@ -726,16 +703,14 @@ namespace OpenSim.Framework int maxConnections) { int reqnum = WebUtil.RequestNumber++; - - if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} AsynchronousRequestObject {1} {2}", - reqnum, verb, requestUrl); + // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); int tickstart = Util.EnvironmentTickCount(); // int tickdata = 0; int tickdiff = 0; +// m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); + Type type = typeof(TRequest); WebRequest request = WebRequest.Create(requestUrl); @@ -893,7 +868,7 @@ namespace OpenSim.Framework } m_log.InfoFormat( - "[ASYNC REQUEST]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", + "[ASYNC REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", reqnum, verb, requestUrl, @@ -908,12 +883,6 @@ namespace OpenSim.Framework requestUrl, tickdiff); } - else if (WebUtil.DebugLevel >= 4) - { - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} took {1}ms", - reqnum, tickdiff); - } } } @@ -934,11 +903,7 @@ namespace OpenSim.Framework public static string MakeRequest(string verb, string requestUrl, string obj) { int reqnum = WebUtil.RequestNumber++; - - if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} SynchronousRestForms {1} {2}", - reqnum, verb, requestUrl); + // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); int tickstart = Util.EnvironmentTickCount(); int tickdata = 0; @@ -1025,7 +990,7 @@ namespace OpenSim.Framework int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); if (tickdiff > WebUtil.LongCallTime) m_log.InfoFormat( - "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", + "[FORMS]: Slow request to <{0}> {1} {2} took {3}ms {4}ms writing {5}", reqnum, verb, requestUrl, @@ -1033,10 +998,6 @@ namespace OpenSim.Framework tickset, tickdata, obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); - else if (WebUtil.DebugLevel >= 4) - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", - reqnum, tickdiff, tickdata); return respstring; } @@ -1071,11 +1032,7 @@ namespace OpenSim.Framework public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) { int reqnum = WebUtil.RequestNumber++; - - if (WebUtil.DebugLevel >= 3) - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} SynchronousRestObject {1} {2}", - reqnum, verb, requestUrl); + // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); int tickstart = Util.EnvironmentTickCount(); int tickdata = 0; @@ -1194,7 +1151,7 @@ namespace OpenSim.Framework } m_log.InfoFormat( - "[SynchronousRestObjectRequester]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", + "[SynchronousRestObjectRequester]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", reqnum, verb, requestUrl, @@ -1202,12 +1159,6 @@ namespace OpenSim.Framework tickdata, originalRequest); } - else if (WebUtil.DebugLevel >= 4) - { - m_log.DebugFormat( - "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", - reqnum, tickdiff, tickdata); - } return deserial; } -- cgit v1.1