From e6d7303b296468a06ada761706e25d49587b308f Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 12:01:40 -0800 Subject: [PATCH 1/8] Applying #4332, optional packet statistics logging --- .../ClientStack/LindenUDP/LLClientView.cs | 4 + .../ClientStack/LindenUDP/LLUDPServer.cs | 111 ++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 100 ++++++++++++++++ 3 files changed, 215 insertions(+) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 34cad7b5cf..101a44bf87 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4905,6 +4905,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Throttling category for the packet protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) { + #region BinaryStats + LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length); + #endregion BinaryStats + m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 6165984c3b..c773c05905 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Net; using System.Net.Sockets; using System.Reflection; @@ -204,6 +205,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP TextureSendLimit = 20; } + #region BinaryStats + config = configSource.Configs["Statistics.Binary"]; + m_shouldCollectStats = false; + if (config != null) + { + if (config.Contains("enabled") && config.GetBoolean("enabled")) + { + if (config.Contains("collect_packet_headers")) + m_shouldCollectStats = config.GetBoolean("collect_packet_headers"); + if (config.Contains("packet_headers_period_seconds")) + { + binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds")); + } + if (config.Contains("stats_dir")) + { + binStatsDir = config.GetString("stats_dir"); + } + } + else + { + m_shouldCollectStats = false; + } + } + #endregion BinaryStats + m_throttle = new TokenBucket(null, sceneThrottleBps, sceneThrottleBps); m_throttleRates = new ThrottleRates(configSource); } @@ -679,6 +705,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Incoming Packet Accounting + #region BinaryStats + LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); + #endregion BinaryStats + #region Ping Check Handling if (packet.Type == PacketType.StartPingCheck) @@ -700,6 +730,87 @@ namespace OpenSim.Region.ClientStack.LindenUDP packetInbox.Enqueue(new IncomingPacket(udpClient, packet)); } + #region BinaryStats + + public class PacketLogger + { + public DateTime StartTime; + public string Path = null; + public System.IO.BinaryWriter Log = null; + } + + public static PacketLogger PacketLog; + + protected static bool m_shouldCollectStats = false; + // Number of seconds to log for + static TimeSpan binStatsMaxFilesize = TimeSpan.FromSeconds(300); + static object binStatsLogLock = new object(); + static string binStatsDir = ""; + + public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size) + { + if (!m_shouldCollectStats) return; + + // Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size + + // Put the incoming bit into the least significant bit of the flags byte + if (incoming) + flags |= 0x01; + else + flags &= 0xFE; + + // Put the flags byte into the most significant bits of the type integer + uint type = (uint)packetType; + type |= (uint)flags << 24; + + // m_log.Debug("1 LogPacketHeader(): Outside lock"); + lock (binStatsLogLock) + { + DateTime now = DateTime.Now; + + // m_log.Debug("2 LogPacketHeader(): Inside lock. now is " + now.Ticks); + try + { + if (PacketLog == null || (now > PacketLog.StartTime + binStatsMaxFilesize)) + { + if (PacketLog != null && PacketLog.Log != null) + { + PacketLog.Log.Close(); + } + + // First log file or time has expired, start writing to a new log file + PacketLog = new PacketLogger(); + PacketLog.StartTime = now; + PacketLog.Path = (binStatsDir.Length > 0 ? binStatsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") + + String.Format("packets-{0}.log", now.ToString("yyyyMMddHHmmss")); + PacketLog.Log = new BinaryWriter(File.Open(PacketLog.Path, FileMode.Append, FileAccess.Write)); + } + + // Serialize the data + byte[] output = new byte[18]; + Buffer.BlockCopy(BitConverter.GetBytes(now.Ticks), 0, output, 0, 8); + Buffer.BlockCopy(BitConverter.GetBytes(circuit), 0, output, 8, 4); + Buffer.BlockCopy(BitConverter.GetBytes(type), 0, output, 12, 4); + Buffer.BlockCopy(BitConverter.GetBytes(size), 0, output, 16, 2); + + // Write the serialized data to disk + if (PacketLog != null && PacketLog.Log != null) + PacketLog.Log.Write(output); + } + catch (Exception ex) + { + m_log.Error("Packet statistics gathering failed: " + ex.Message, ex); + if (PacketLog.Log != null) + { + PacketLog.Log.Close(); + } + PacketLog = null; + } + } + } + + #endregion BinaryStats + private void HandleUseCircuitCode(object o) { object[] array = (object[])o; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 093ca3ef1d..6edef11e0f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -36,6 +36,7 @@ using System.Timers; using System.Xml; using Nini.Config; using OpenMetaverse; +using OpenMetaverse.Packets; using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Services.Interfaces; @@ -397,6 +398,73 @@ namespace OpenSim.Region.Framework.Scenes #endregion + #region BinaryStats + + public class StatLogger + { + public DateTime StartTime; + public string Path; + public System.IO.BinaryWriter Log; + } + static StatLogger m_statLog = null; + static TimeSpan m_statLogPeriod = TimeSpan.FromSeconds(300); + static string m_statsDir = String.Empty; + static Object m_statLockObject = new Object(); + private void LogSimStats(SimStats stats) + { + SimStatsPacket pack = new SimStatsPacket(); + pack.Region = new SimStatsPacket.RegionBlock(); + pack.Region.RegionX = stats.RegionX; + pack.Region.RegionY = stats.RegionY; + pack.Region.RegionFlags = stats.RegionFlags; + pack.Region.ObjectCapacity = stats.ObjectCapacity; + //pack.Region = //stats.RegionBlock; + pack.Stat = stats.StatsBlock; + pack.Header.Reliable = false; + + // note that we are inside the reporter lock when called + DateTime now = DateTime.Now; + + // hide some time information into the packet + pack.Header.Sequence = (uint)now.Ticks; + + lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here + { + try + { + if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) + { + // First log file or time has expired, start writing to a new log file + if (m_statLog != null && m_statLog.Log != null) + { + m_statLog.Log.Close(); + } + m_statLog = new StatLogger(); + m_statLog.StartTime = now; + m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") + + String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")); + m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); + } + + // Write the serialized data to disk + if (m_statLog != null && m_statLog.Log != null) + m_statLog.Log.Write(pack.ToBytes()); + } + catch (Exception ex) + { + m_log.Error("statistics gathering failed: " + ex.Message, ex); + if (m_statLog != null && m_statLog.Log != null) + { + m_statLog.Log.Close(); + } + m_statLog = null; + } + } + return; + } + + #endregion + #region Constructors public Scene(RegionInfo regInfo, AgentCircuitManager authen, @@ -582,6 +650,38 @@ namespace OpenSim.Region.Framework.Scenes } m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); + + #region BinaryStats + + try + { + IConfig statConfig = m_config.Configs["Statistics.Binary"]; + if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) + { + if (statConfig.Contains("collect_region_stats")) + { + if (statConfig.GetBoolean("collect_region_stats")) + { + // if enabled, add us to the event. If not enabled, I won't get called + StatsReporter.OnSendStatsResult += LogSimStats; + } + } + if (statConfig.Contains("region_stats_period_seconds")) + { + m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds")); + } + if (statConfig.Contains("stats_dir")) + { + m_statsDir = statConfig.GetString("stats_dir"); + } + } + } + catch + { + // if it doesn't work, we don't collect anything + } + + #endregion BinaryStats } catch { From afef1ac191d32e9c1514c294b17e404b1d4ae217 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 13:10:58 -0800 Subject: [PATCH 2/8] Changing the AssetBase constructors to avoid initializing assets with an unknown asset type, and log an error if it ever does happen --- .../RemoteController/RemoteAdminPlugin.cs | 5 +-- .../Rest/Inventory/RestAssetServices.cs | 10 +---- .../Rest/Inventory/RestInventoryServices.cs | 3 +- OpenSim/Data/MSSQL/MSSQLAssetData.cs | 9 ++-- OpenSim/Data/MySQL/MySQLAssetData.cs | 5 +-- OpenSim/Data/SQLite/SQLiteAssetData.cs | 9 ++-- OpenSim/Data/Tests/BasicAssetTest.cs | 6 +-- .../Data/Tests/PropertyCompareConstraint.cs | 12 +++--- OpenSim/Data/Tests/PropertyScrambler.cs | 5 +-- OpenSim/Framework/AssetBase.cs | 42 +++++++++++++++---- OpenSim/Framework/AssetLandmark.cs | 4 +- .../Filesystem/AssetLoaderFileSystem.cs | 21 ++++++---- OpenSim/Framework/Capabilities/Caps.cs | 5 +-- OpenSim/Framework/Tests/AssetBaseTest.cs | 3 +- .../ClientStack/LindenUDP/LLFileTransfer.cs | 5 +-- .../AssetTransaction/AssetXferUploader.cs | 5 +-- .../Agent/TextureSender/J2KDecoderModule.cs | 7 ++-- .../Archiver/InventoryArchiveReadRequest.cs | 7 ++-- .../Archiver/Tests/InventoryArchiverTests.cs | 3 +- .../DynamicTexture/DynamicTextureModule.cs | 5 +-- .../World/Archiver/ArchiveReadRequest.cs | 6 ++- .../World/Archiver/AssetsDearchiver.cs | 3 +- .../World/Estate/EstateTerrainXferHandler.cs | 7 +--- .../World/WorldMap/WorldMapModule.cs | 10 ++--- .../Scenes/Hypergrid/HGAssetMapper.cs | 2 +- .../Framework/Scenes/Scene.Inventory.cs | 5 +-- .../Region/Framework/Scenes/ScenePresence.cs | 6 +-- .../Scripting/Minimodule/Graphics.cs | 5 +-- .../Shared/Api/Implementation/OSSL_Api.cs | 7 +--- .../Connectors/Asset/AssetServiceConnector.cs | 2 +- .../Grid/HypergridServiceConnector.cs | 3 +- 31 files changed, 105 insertions(+), 122 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 3c7727f738..3149eaa60b 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -1562,11 +1562,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController assets = doc.GetElementsByTagName("RequiredAsset"); foreach (XmlNode asset in assets) { - AssetBase rass = new AssetBase(); - rass.FullID = UUID.Random(); - rass.Name = GetStringAttribute(asset,"name",""); + AssetBase rass = new AssetBase(UUID.Random(), GetStringAttribute(asset,"name",""), SByte.Parse(GetStringAttribute(asset,"type",""))); rass.Description = GetStringAttribute(asset,"desc",""); - rass.Type = SByte.Parse(GetStringAttribute(asset,"type","")); rass.Local = Boolean.Parse(GetStringAttribute(asset,"local","")); rass.Temporary = Boolean.Parse(GetStringAttribute(asset,"temporary","")); rass.Data = Convert.FromBase64String(asset.InnerText); diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs index f862af1fb7..66572d5f5a 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs @@ -261,11 +261,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory modified = (asset != null); created = !modified; - asset = new AssetBase(); - asset.FullID = uuid; - asset.Name = xml.GetAttribute("name"); + asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type"))); asset.Description = xml.GetAttribute("desc"); - asset.Type = SByte.Parse(xml.GetAttribute("type")); asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0; asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0; asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", "")); @@ -341,11 +338,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory modified = (asset != null); created = !modified; - asset = new AssetBase(); - asset.FullID = uuid; - asset.Name = xml.GetAttribute("name"); + asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type"))); asset.Description = xml.GetAttribute("desc"); - asset.Type = SByte.Parse(xml.GetAttribute("type")); asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0; asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0; asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", "")); diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index 4e03e67c3e..01bfe00686 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs @@ -1869,10 +1869,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // Create AssetBase entity to hold the inlined asset - asset = new AssetBase(uuid, name); + asset = new AssetBase(uuid, name, type); asset.Description = desc; - asset.Type = type; // type == 0 == texture asset.Local = local; asset.Temporary = temp; diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 25f7cf019e..1ce4abfd16 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs @@ -132,12 +132,13 @@ namespace OpenSim.Data.MSSQL { if (reader.Read()) { - AssetBase asset = new AssetBase(); + AssetBase asset = new AssetBase( + new UUID((Guid)reader["id"]), + (string)reader["name"], + Convert.ToSByte(reader["assetType"]) + ); // Region Main - asset.FullID = new UUID((Guid)reader["id"]); - asset.Name = (string)reader["name"]; asset.Description = (string)reader["description"]; - asset.Type = Convert.ToSByte(reader["assetType"]); asset.Local = Convert.ToBoolean(reader["local"]); asset.Temporary = Convert.ToBoolean(reader["temporary"]); asset.Data = (byte[])reader["data"]; diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 1fe6d2953d..6a4ccd7057 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -151,10 +151,9 @@ namespace OpenSim.Data.MySQL { if (dbReader.Read()) { - asset = new AssetBase(); + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); asset.Data = (byte[]) dbReader["data"]; asset.Description = (string) dbReader["description"]; - asset.FullID = assetID; string local = dbReader["local"].ToString(); if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) @@ -162,8 +161,6 @@ namespace OpenSim.Data.MySQL else asset.Local = false; - asset.Name = (string) dbReader["name"]; - asset.Type = (sbyte) dbReader["assetType"]; asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } dbReader.Close(); diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 49275cbbae..11be28e2bf 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -231,12 +231,13 @@ namespace OpenSim.Data.SQLite // TODO: this doesn't work yet because something more // interesting has to be done to actually get these values // back out. Not enough time to figure it out yet. - AssetBase asset = new AssetBase(); + AssetBase asset = new AssetBase( + new UUID((String)row["UUID"]), + (String)row["Name"], + Convert.ToSByte(row["Type"]) + ); - asset.FullID = new UUID((String) row["UUID"]); - asset.Name = (String) row["Name"]; asset.Description = (String) row["Description"]; - asset.Type = Convert.ToSByte(row["Type"]); asset.Local = Convert.ToBoolean(row["Local"]); asset.Temporary = Convert.ToBoolean(row["Temporary"]); asset.Data = (byte[]) row["Data"]; diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index 1969d76a44..25aed61866 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs @@ -66,9 +66,9 @@ namespace OpenSim.Data.Tests [Test] public void T010_StoreSimpleAsset() { - AssetBase a1 = new AssetBase(uuid1, "asset one"); - AssetBase a2 = new AssetBase(uuid2, "asset two"); - AssetBase a3 = new AssetBase(uuid3, "asset three"); + AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); + AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture); + AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture); a1.Data = asset1; a2.Data = asset1; a3.Data = asset1; diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs index 06ca53ec90..5b1f935604 100644 --- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs +++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs @@ -297,8 +297,8 @@ namespace OpenSim.Data.Tests public void AssetShouldMatch() { UUID uuid1 = UUID.Random(); - AssetBase actual = new AssetBase(uuid1, "asset one"); - AssetBase expected = new AssetBase(uuid1, "asset one"); + AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); + AssetBase expected = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); var constraint = Constraints.PropertyCompareConstraint(expected); @@ -309,8 +309,8 @@ namespace OpenSim.Data.Tests public void AssetShouldNotMatch() { UUID uuid1 = UUID.Random(); - AssetBase actual = new AssetBase(uuid1, "asset one"); - AssetBase expected = new AssetBase(UUID.Random(), "asset one"); + AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); + AssetBase expected = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); var constraint = Constraints.PropertyCompareConstraint(expected); @@ -321,8 +321,8 @@ namespace OpenSim.Data.Tests public void AssetShouldNotMatch2() { UUID uuid1 = UUID.Random(); - AssetBase actual = new AssetBase(uuid1, "asset one"); - AssetBase expected = new AssetBase(uuid1, "asset two"); + AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); + AssetBase expected = new AssetBase(uuid1, "asset two", (sbyte)AssetType.Texture); var constraint = Constraints.PropertyCompareConstraint(expected); diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs index 72aaff1d0a..c968364919 100644 --- a/OpenSim/Data/Tests/PropertyScrambler.cs +++ b/OpenSim/Data/Tests/PropertyScrambler.cs @@ -165,7 +165,7 @@ namespace OpenSim.Data.Tests [Test] public void TestScramble() { - AssetBase actual = new AssetBase(UUID.Random(), "asset one"); + AssetBase actual = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); new PropertyScrambler().Scramble(actual); } @@ -173,8 +173,7 @@ namespace OpenSim.Data.Tests public void DontScramble() { UUID uuid = UUID.Random(); - AssetBase asset = new AssetBase(); - asset.FullID = uuid; + AssetBase asset = new AssetBase(uuid, "asset", (sbyte)AssetType.Texture); new PropertyScrambler() .DontScramble(x => x.Metadata) .DontScramble(x => x.FullID) diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 9679ff2512..eed97034d6 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -27,6 +27,8 @@ using System; using System.Xml.Serialization; +using System.Reflection; +using log4net; using OpenMetaverse; namespace OpenSim.Framework @@ -37,6 +39,8 @@ namespace OpenSim.Framework [Serializable] public class AssetBase { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// /// Data of the Asset /// @@ -47,16 +51,34 @@ namespace OpenSim.Framework /// private AssetMetadata m_metadata; - public AssetBase() + public AssetBase(UUID assetID, string name, sbyte assetType) { + if (assetType == (sbyte)AssetType.Unknown) + { + System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true); + m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}", + name, assetID, trace.ToString()); + } + m_metadata = new AssetMetadata(); + m_metadata.FullID = assetID; + m_metadata.Name = name; + m_metadata.Type = assetType; } - public AssetBase(UUID assetId, string name) + public AssetBase(string assetID, string name, sbyte assetType) { + if (assetType == (sbyte)AssetType.Unknown) + { + System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true); + m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}", + name, assetID, trace.ToString()); + } + m_metadata = new AssetMetadata(); - m_metadata.FullID = assetId; + m_metadata.ID = assetID; m_metadata.Name = name; + m_metadata.Type = assetType; } public bool ContainsReferences @@ -193,11 +215,11 @@ namespace OpenSim.Framework private string m_name = String.Empty; private string m_description = String.Empty; private DateTime m_creation_date; - private sbyte m_type; + private sbyte m_type = (sbyte)AssetType.Unknown; private string m_content_type; private byte[] m_sha1; - private bool m_local = false; - private bool m_temporary = false; + private bool m_local; + private bool m_temporary; //private Dictionary m_methods = new Dictionary(); //private OSDMap m_extra_data; @@ -211,7 +233,13 @@ namespace OpenSim.Framework { //get { return m_fullid.ToString(); } //set { m_fullid = new UUID(value); } - get { return m_id; } + get + { + if (String.IsNullOrEmpty(m_id)) + m_id = m_fullid.ToString(); + + return m_id; + } set { UUID uuid = UUID.Zero; diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs index fd7a2cd184..058b442d58 100644 --- a/OpenSim/Framework/AssetLandmark.cs +++ b/OpenSim/Framework/AssetLandmark.cs @@ -38,11 +38,9 @@ namespace OpenSim.Framework public int Version; public AssetLandmark(AssetBase a) + : base(a.FullID, a.Name, a.Type) { Data = a.Data; - FullID = a.FullID; - Type = a.Type; - Name = a.Name; Description = a.Description; InternData(); } diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index a394b1afd1..9497a2e882 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs @@ -43,18 +43,15 @@ namespace OpenSim.Framework.AssetLoader.Filesystem { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected static AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage) + protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type) { - AssetBase asset = new AssetBase( - new UUID(assetIdStr), - name - ); + AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type); if (!String.IsNullOrEmpty(path)) { //m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path); - LoadAsset(asset, isImage, path); + LoadAsset(asset, path); } else { @@ -64,8 +61,14 @@ namespace OpenSim.Framework.AssetLoader.Filesystem return asset; } - protected static void LoadAsset(AssetBase info, bool image, string path) + protected static void LoadAsset(AssetBase info, string path) { + bool image = + (info.Type == (sbyte)AssetType.Texture || + info.Type == (sbyte)AssetType.TextureTGA || + info.Type == (sbyte)AssetType.ImageJPEG || + info.Type == (sbyte)AssetType.ImageTGA); + FileInfo fInfo = new FileInfo(path); long numBytes = fInfo.Length; if (fInfo.Exists) @@ -138,10 +141,10 @@ namespace OpenSim.Framework.AssetLoader.Filesystem { string assetIdStr = source.Configs[i].GetString("assetID", UUID.Random().ToString()); string name = source.Configs[i].GetString("name", String.Empty); - sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); + sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty)); - AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false); + AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, type); newAsset.Type = type; assets.Add(newAsset); diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index ccfe800e17..72231ca55c 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs @@ -888,10 +888,7 @@ namespace OpenSim.Framework.Capabilities } AssetBase asset; - asset = new AssetBase(); - asset.FullID = assetID; - asset.Type = assType; - asset.Name = assetName; + asset = new AssetBase(assetID, assetName, assType); asset.Data = data; if (AddNewAsset != null) AddNewAsset(asset); diff --git a/OpenSim/Framework/Tests/AssetBaseTest.cs b/OpenSim/Framework/Tests/AssetBaseTest.cs index 3dc6b4ee4f..18a3e011d5 100644 --- a/OpenSim/Framework/Tests/AssetBaseTest.cs +++ b/OpenSim/Framework/Tests/AssetBaseTest.cs @@ -67,8 +67,7 @@ namespace OpenSim.Framework.Tests private void CheckContainsReferences(AssetType assetType, bool expected) { - AssetBase asset = new AssetBase(); - asset.Type = (sbyte)assetType; + AssetBase asset = new AssetBase(UUID.Zero, String.Empty, (sbyte)assetType); bool actual = asset.ContainsReferences; Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+"."); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs index 697bbe6325..adf171e465 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs @@ -197,11 +197,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void Initialise(UUID fileID, string fileName) { - m_asset = new AssetBase(); - m_asset.FullID = fileID; - m_asset.Type = type; + m_asset = new AssetBase(fileID, fileName, type); m_asset.Data = new byte[0]; - m_asset.Name = fileName; m_asset.Description = "empty"; m_asset.Local = true; m_asset.Temporary = true; diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index e192b8163e..f698ea13c7 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -112,11 +112,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction bool storeLocal, bool tempFile) { ourClient = remoteClient; - m_asset = new AssetBase(); - m_asset.FullID = assetID; - m_asset.Type = type; + m_asset = new AssetBase(assetID, "blank", type); m_asset.Data = data; - m_asset.Name = "blank"; m_asset.Description = "empty"; m_asset.Local = storeLocal; m_asset.Temporary = tempFile; diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 7456e8c04f..5fde35f057 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -238,12 +238,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender if (m_cache != null) { - AssetBase layerDecodeAsset = new AssetBase(); - layerDecodeAsset.ID = "j2kCache_" + AssetId.ToString(); + string assetID = "j2kCache_" + AssetId.ToString(); + + AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard); layerDecodeAsset.Local = true; - layerDecodeAsset.Name = layerDecodeAsset.ID; layerDecodeAsset.Temporary = true; - layerDecodeAsset.Type = (sbyte)AssetType.Notecard; #region Serialize Layer Data diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index f761bf0c53..a4445eb203 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -389,11 +389,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; + if (assetType == (sbyte)AssetType.Unknown) + m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); + //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), "RandomName"); - - asset.Type = assetType; + AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType); asset.Data = data; m_scene.AssetService.Store(asset); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index b0fdcd6f33..8ee9194533 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -122,8 +122,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = new AssetBase(); - asset1.FullID = asset1Id; + AssetBase asset1 = new AssetBase(asset1Id, asset1Id.ToString(), (sbyte)AssetType.Object); asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); scene.AssetService.Store(asset1); diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 9a6c49aae0..43761fce62 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -311,11 +311,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture } // Create a new asset for user - AssetBase asset = new AssetBase(); - asset.FullID = UUID.Random(); + AssetBase asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture); asset.Data = assetData; - asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); - asset.Type = 0; asset.Description = String.Format("URL image : {0}", Url); asset.Local = false; asset.Temporary = ((Disp & DISP_TEMP) != 0); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index c261943a3c..70a225e7c1 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -332,10 +332,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; + if (assetType == (sbyte)AssetType.Unknown) + m_log.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); + //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), String.Empty); - asset.Type = assetType; + AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType); asset.Data = data; // We're relying on the asset service to do the sensible thing and not store the asset if it already diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs index 5208e7abbf..2d2c570447 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs @@ -158,9 +158,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); - AssetBase asset = new AssetBase(new UUID(filename), metadata.Name); + AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType); asset.Description = metadata.Description; - asset.Type = metadata.AssetType; asset.Data = data; m_cache.Store(asset); diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs index ddac51596a..2ff635b1ff 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs @@ -52,16 +52,11 @@ namespace OpenSim.Region.CoreModules.World.Estate public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) { - - m_asset = new AssetBase(); - m_asset.FullID = UUID.Zero; - m_asset.Type = type; + m_asset = new AssetBase(UUID.Zero, pClientFilename, type); m_asset.Data = new byte[0]; - m_asset.Name = pClientFilename; m_asset.Description = "empty"; m_asset.Local = true; m_asset.Temporary = true; - } public ulong XferID diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index f4b54aa0a7..44a651f627 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1077,14 +1077,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scene.RegionInfo.RegionSettings.TerrainImageID = TerrainImageUUID; - AssetBase asset = new AssetBase(); - asset.FullID = m_scene.RegionInfo.RegionSettings.TerrainImageID; + AssetBase asset = new AssetBase( + m_scene.RegionInfo.RegionSettings.TerrainImageID, + "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(), + (sbyte)AssetType.Texture); asset.Data = data; - asset.Name - = "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); asset.Description = m_scene.RegionInfo.RegionName; - - asset.Type = 0; asset.Temporary = temporary; m_scene.AssetService.Store(asset); } diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 7a66d23ee1..ec50598f3b 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid // HGAssetService dispatches it to the remote grid. // It's not pretty, but the best that can be done while // not having a global naming infrastructure - AssetBase asset1 = new AssetBase(); + AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); Copy(asset, asset1); try { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 00743fcf3c..6b2c7d335b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -627,11 +627,8 @@ namespace OpenSim.Region.Framework.Scenes /// private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) { - AssetBase asset = new AssetBase(); - asset.Name = name; + AssetBase asset = new AssetBase(UUID.Random(), name, assetType); asset.Description = description; - asset.Type = assetType; - asset.FullID = UUID.Random(); asset.Data = (data == null) ? new byte[1] : data; return asset; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1e9201e303..17026e515e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1918,14 +1918,10 @@ namespace OpenSim.Region.Framework.Scenes } - AssetBase Animasset = new AssetBase(); + AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); Animasset.Data = anim.ToBytes(); Animasset.Temporary = true; Animasset.Local = true; - Animasset.FullID = UUID.Random(); - Animasset.ID = Animasset.FullID.ToString(); - Animasset.Name = "Random Animation"; - Animasset.Type = (sbyte)AssetType.Animation; Animasset.Description = "dance"; //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 963cab5bb8..8ea7ad39e4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -49,11 +49,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) { - AssetBase asset = new AssetBase(); - asset.FullID = UUID.Random(); + AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture); asset.Data = OpenJPEG.EncodeFromImage(data, lossless); - asset.Name = "MRMDynamicImage"; - asset.Type = 0; asset.Description = "MRM Image"; asset.Local = false; asset.Temporary = temporary; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f1ceb80ca6..f7ee3d99ab 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1483,12 +1483,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // Create new asset - AssetBase asset = new AssetBase(); - asset.Name = notecardName; + AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard); asset.Description = "Script Generated Notecard"; - asset.Type = 7; - asset.FullID = UUID.Random(); - string notecardData = ""; + string notecardData = String.Empty; for (int i = 0; i < contents.Length; i++) { notecardData += contents.GetLSLStringItem(i) + "\n"; diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index ecda85a9e3..8e311d70d8 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs @@ -243,7 +243,7 @@ namespace OpenSim.Services.Connectors if (metadata == null) return false; - asset = new AssetBase(); + asset = new AssetBase(metadata.FullID, metadata.Name, metadata.Type); asset.Metadata = metadata; } asset.Data = data; diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 3d7f112cfe..2f33babe95 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -140,12 +140,11 @@ namespace OpenSim.Services.Connectors.Grid Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); byte[] imageData = OpenJPEG.EncodeFromImage(m, true); - AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); + AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString(), (sbyte)AssetType.Texture); // !!! for now //info.RegionSettings.TerrainImageID = ass.FullID; - ass.Type = (int)AssetType.Texture; ass.Temporary = true; ass.Local = true; ass.Data = imageData; From 6ed57814c1db72463acc3c5fca154a289eee433e Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 23:50:17 -0800 Subject: [PATCH 3/8] * Clamp the CoarseLocationUpdate packet at a maximum of 60 positions per packet. This is a limitation of LLUDP, nothing we can really do about it * Marking CoarseLocationUpdate as *not* zerocoded. Zerocoding can only save space when a packet contains three or more contiguous zeroes, and will use more space if it contains single zeroes randomly scattered through the packet (which is what you see when you send a long list of UUIDs) --- .../ClientStack/LindenUDP/LLClientView.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 101a44bf87..35ccad9221 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3196,12 +3196,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (!IsActive) return; // We don't need to update inactive clients. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); - // TODO: don't create new blocks if recycling an old packet - int total = CoarseLocations.Count; - CoarseLocationUpdatePacket.IndexBlock ib = - new CoarseLocationUpdatePacket.IndexBlock(); + loc.Header.Reliable = false; + + // Each packet can only hold around 62 avatar positions and the client clears the mini-map each time + // a CoarseLocationUpdate packet is received. Oh well. + int total = Math.Min(CoarseLocations.Count, 60); + + CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock(); + loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total]; + int selfindex = -1; for (int i = 0; i < total; i++) { @@ -3211,18 +3216,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP lb.X = (byte)CoarseLocations[i].X; lb.Y = (byte)CoarseLocations[i].Y; - lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25); + lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f); loc.Location[i] = lb; loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock(); loc.AgentData[i].AgentID = users[i]; if (users[i] == AgentId) selfindex = i; } + ib.You = (short)selfindex; ib.Prey = -1; loc.Index = ib; - loc.Header.Reliable = false; - loc.Header.Zerocoded = true; OutPacket(loc, ThrottleOutPacketType.Task); } From 1cddc850783c4dcf49ca3cd845fdc811ffb20dea Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 6 Nov 2009 00:06:49 -0800 Subject: [PATCH 4/8] Fixing the build break --- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 41bb9dc5ef..e300eb1852 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -337,8 +337,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = new AssetBase(); - asset1.FullID = asset1Id; + AssetBase asset1 = new AssetBase(asset1Id, String.Empty, (sbyte)AssetType.Object); asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); scene.AssetService.Store(asset1); From 5300e8506da657118dbde8c9edc9a00db28bc4ac Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Nov 2009 10:33:49 +0000 Subject: [PATCH 5/8] Reintroduce AssetBase's old behavior. A Parameterless constructor is required for .NET serialization and removing it breaks the OpenSim asset server protocol. --- OpenSim/Framework/AssetBase.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index eed97034d6..212f41de39 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -51,6 +51,16 @@ namespace OpenSim.Framework /// private AssetMetadata m_metadata; + // This is needed for .NET serialization!!! + // Do NOT "Optimize" away! + public AssetBase() + { + m_metadata = new AssetMetadata(); + m_metadata.FullID = UUID.Zero; + m_metadata.ID = UUID.Zero.ToString(); + m_metadata.Type = (sbyte)AssetType.Unknown; + } + public AssetBase(UUID assetID, string name, sbyte assetType) { if (assetType == (sbyte)AssetType.Unknown) From 81c439bcaadee10a89e74cb65217c7910d943741 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Nov 2009 20:36:00 +0000 Subject: [PATCH 6/8] Patch from Snoopy2. Fixes Mantis #4342 fixes problems when group owned land was abandoned by the land owner or reclaimed by the estate manager or by god. Beside that this new patch makes it possible, that users can buy land directly for a group, if the buyer has the required permissions. --- .../World/Land/LandManagementModule.cs | 11 +++-- .../CoreModules/World/Land/LandObject.cs | 40 ++++++++++++++++--- .../Framework/Interfaces/ILandObject.cs | 1 + 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 93a949a249..968f46a50f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -1059,9 +1059,11 @@ namespace OpenSim.Region.CoreModules.World.Land if (m_scene.Permissions.IsGod(remote_client.AgentId)) { land.LandData.OwnerID = ownerID; + land.LandData.GroupID = UUID.Zero; + land.LandData.IsGroupOwned = false; m_scene.ForEachClient(SendParcelOverlay); - land.SendLandUpdateToClient(remote_client); + land.SendLandUpdateToClient(true, remote_client); } } } @@ -1082,8 +1084,10 @@ namespace OpenSim.Region.CoreModules.World.Land land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; else land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; + land.LandData.GroupID = UUID.Zero; + land.LandData.IsGroupOwned = false; m_scene.ForEachClient(SendParcelOverlay); - land.SendLandUpdateToClient(remote_client); + land.SendLandUpdateToClient(true, remote_client); } } } @@ -1105,9 +1109,10 @@ namespace OpenSim.Region.CoreModules.World.Land else land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; land.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); + land.LandData.GroupID = UUID.Zero; land.LandData.IsGroupOwned = false; m_scene.ForEachClient(SendParcelOverlay); - land.SendLandUpdateToClient(remote_client); + land.SendLandUpdateToClient(true, remote_client); } } } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index bfe85f1e04..0bd225ebe4 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -49,6 +49,8 @@ namespace OpenSim.Region.CoreModules.World.Land #pragma warning restore 0429 private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; + private int m_lastSeqId = 0; + protected LandData m_landData = new LandData(); protected Scene m_scene; protected List primsOverMe = new List(); @@ -81,6 +83,10 @@ namespace OpenSim.Region.CoreModules.World.Land { m_scene = scene; LandData.OwnerID = owner_id; + if (is_group_owned) + LandData.GroupID = owner_id; + else + LandData.GroupID = UUID.Zero; LandData.IsGroupOwned = is_group_owned; } @@ -172,7 +178,19 @@ namespace OpenSim.Region.CoreModules.World.Land // regionFlags |= (uint)RegionFlags.AllowLandmark; // if (landData.OwnerID == remote_client.AgentId) // regionFlags |= (uint)RegionFlags.AllowSetHome; - remote_client.SendLandProperties(sequence_id, + + int seq_id; + if (snap_selection && (sequence_id == 0)) + { + seq_id = m_lastSeqId; + } + else + { + seq_id = sequence_id; + m_lastSeqId = seq_id; + } + + remote_client.SendLandProperties(seq_id, snap_selection, request_result, LandData, (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, GetParcelMaxPrimCount(this), @@ -184,6 +202,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (m_scene.Permissions.CanEditParcel(remote_client.AgentId,this)) { //Needs later group support + bool snap_selection = false; LandData newData = LandData.Copy(); if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice) @@ -192,6 +211,7 @@ namespace OpenSim.Region.CoreModules.World.Land { newData.AuthBuyerID = args.AuthBuyerID; newData.SalePrice = args.SalePrice; + snap_selection = true; } } newData.Category = args.Category; @@ -212,7 +232,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - SendLandUpdateToAvatarsOverMe(); + SendLandUpdateToAvatarsOverMe(snap_selection); } } @@ -230,7 +250,7 @@ namespace OpenSim.Region.CoreModules.World.Land newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects); m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - SendLandUpdateToAvatarsOverMe(); + SendLandUpdateToAvatarsOverMe(true); } public void DeedToGroup(UUID groupID) @@ -242,7 +262,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - SendLandUpdateToAvatarsOverMe(); + SendLandUpdateToAvatarsOverMe(true); } public bool IsEitherBannedOrRestricted(UUID avatar) @@ -297,7 +317,17 @@ namespace OpenSim.Region.CoreModules.World.Land SendLandProperties(0, false, 0, remote_client); } + public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client) + { + SendLandProperties(0, snap_selection, 0, remote_client); + } + public void SendLandUpdateToAvatarsOverMe() + { + SendLandUpdateToAvatarsOverMe(false); + } + + public void SendLandUpdateToAvatarsOverMe(bool snap_selection) { List avatars = m_scene.GetAvatars(); ILandObject over = null; @@ -325,7 +355,7 @@ namespace OpenSim.Region.CoreModules.World.Land else avatars[i].Invulnerable = true; - SendLandUpdateToClient(avatars[i].ControllingClient); + SendLandUpdateToClient(snap_selection, avatars[i].ControllingClient); } } } diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs index c2b1292864..084184ffb4 100644 --- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs +++ b/OpenSim/Region/Framework/Interfaces/ILandObject.cs @@ -54,6 +54,7 @@ namespace OpenSim.Region.Framework.Interfaces bool IsBannedFromLand(UUID avatar); bool IsRestrictedFromLand(UUID avatar); void SendLandUpdateToClient(IClientAPI remote_client); + void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); List CreateAccessListArrayByFlag(AccessList flag); void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); void UpdateAccessList(uint flags, List entries, IClientAPI remote_client); From aff5fe10b0ad95489909f74f9ee2f6bb85f3d338 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Nov 2009 22:29:36 +0000 Subject: [PATCH 7/8] test commit with debug output per folder fetch. NOT FOR PRODUCTION, SPEWY --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 35ccad9221..06ce79daa7 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1255,6 +1255,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP List folders, int version, bool fetchFolders, bool fetchItems) { + m_log.DebugFormat("[CLIENT]: Request folder details for folder {0}", folderID.ToString()); // An inventory descendents packet consists of a single agent section and an inventory details // section for each inventory item. The size of each inventory item is approximately 550 bytes. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent From f8bcbe5492330bd14ecec76f11e3a33ea4fd6ef6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Nov 2009 22:39:00 +0000 Subject: [PATCH 8/8] remove the debug stuff --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 06ce79daa7..35ccad9221 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1255,7 +1255,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP List folders, int version, bool fetchFolders, bool fetchItems) { - m_log.DebugFormat("[CLIENT]: Request folder details for folder {0}", folderID.ToString()); // An inventory descendents packet consists of a single agent section and an inventory details // section for each inventory item. The size of each inventory item is approximately 550 bytes. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent