From 08d8a3e5808b790fbbd7ba3f460603db66aeaff2 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Mon, 18 Apr 2011 16:48:49 -0700 Subject: Requeue unacknowledged entity updates rather than resend then "as is". Often, by the time the UDPServer realizes that an entity update packet has not been acknowledged, there is a newer update for the same entity already queued up or there is a higher priority update that should be sent first. This patch eliminates 1:1 packet resends for unacked entity update packets. Insteawd, unacked update packets are decomposed into the original entity updates and those updates are placed back into the priority queues based on their new priority but the original update timestamp. This will generally place them at the head of the line to be put back on the wire as a new outgoing packet but prevents the resend queue from filling up with multiple stale updates for the same entity. This new approach takes advantage of the UDP nature of the Linden protocol in that the intent of a reliable update packet is that if it goes unacknowledge, SOMETHING has to happen to get the update to the client. We are simply making sure that we are resending current object state rather than stale object state. Additionally, this patch includes a generalized callback mechanism so that any caller can specify their own method to call when a packet expires without being acknowledged. We use this mechanism to requeue update packets and otherwise use the UDPServer default method of just putting expired packets in the resend queue. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 96 +++++++++++++++++----- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 64 +++++++-------- .../Region/ClientStack/LindenUDP/OutgoingPacket.cs | 6 +- 3 files changed, 112 insertions(+), 54 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 1f7e66d..14c5d6c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3561,6 +3561,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation)); } + /// + /// Requeue an EntityUpdate when it was not acknowledged by the client. + /// We will update the priority and put it in the correct queue, merging update flags + /// with any other updates that may be queued for the same entity. + /// The original update time is used for the merged update. + /// + public void ResendPrimUpdate(EntityUpdate update) + { + // If the update exists in priority queue, it will be updated. + // If it does not exist then it will be added with the current (rather than its original) priority + uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity); + + lock (m_entityUpdates.SyncRoot) + m_entityUpdates.Enqueue(priority, update); + } + + /// + /// Requeue a list of EntityUpdates when they were not acknowledged by the client. + /// We will update the priority and put it in the correct queue, merging update flags + /// with any other updates that may be queued for the same entity. + /// The original update time is used for the merged update. + /// + void ResendPrimUpdates(List updates) + { + foreach (EntityUpdate update in updates) + ResendPrimUpdate(update); + } + private void ProcessEntityUpdates(int maxUpdates) { OpenSim.Framework.Lazy> objectUpdateBlocks = new OpenSim.Framework.Lazy>(); @@ -3568,6 +3596,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP OpenSim.Framework.Lazy> terseUpdateBlocks = new OpenSim.Framework.Lazy>(); OpenSim.Framework.Lazy> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy>(); + OpenSim.Framework.Lazy> objectUpdates = new OpenSim.Framework.Lazy>(); + OpenSim.Framework.Lazy> compressedUpdates = new OpenSim.Framework.Lazy>(); + OpenSim.Framework.Lazy> terseUpdates = new OpenSim.Framework.Lazy>(); + OpenSim.Framework.Lazy> terseAgentUpdates = new OpenSim.Framework.Lazy>(); + // Check to see if this is a flush if (maxUpdates <= 0) { @@ -3583,7 +3616,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP float avgTimeDilation = 1.0f; IEntityUpdate iupdate; Int32 timeinqueue; // this is just debugging code & can be dropped later - + while (updatesThisCall < maxUpdates) { lock (m_entityUpdates.SyncRoot) @@ -3688,24 +3721,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (update.Entity is ScenePresence) { objectUpdateBlocks.Value.Add(CreateAvatarUpdateBlock((ScenePresence)update.Entity)); + objectUpdates.Value.Add(update); } else { objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId)); + objectUpdates.Value.Add(update); } } else if (!canUseImproved) { compressedUpdateBlocks.Value.Add(CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags)); + compressedUpdates.Value.Add(update); } else { if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId) + { // Self updates go into a special list terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures))); + terseAgentUpdates.Value.Add(update); + } else + { // Everything else goes here terseUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures))); + terseUpdates.Value.Add(update); + } } #endregion Block Construction @@ -3713,28 +3755,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Packet Sending - - //const float TIME_DILATION = 1.0f; - - ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f); - + if (terseAgentUpdateBlocks.IsValueCreated) { List blocks = terseAgentUpdateBlocks.Value; - + ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket(); packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle; packet.RegionData.TimeDilation = timeDilation; packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count]; - + for (int i = 0; i < blocks.Count; i++) packet.ObjectData[i] = blocks[i]; - - - OutPacket(packet, ThrottleOutPacketType.Unknown, true); + // If any of the packets created from this call go unacknowledged, all of the updates will be resent + OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate() { ResendPrimUpdates(terseAgentUpdates.Value); }); } - + if (objectUpdateBlocks.IsValueCreated) { List blocks = objectUpdateBlocks.Value; @@ -3746,8 +3783,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < blocks.Count; i++) packet.ObjectData[i] = blocks[i]; - - OutPacket(packet, ThrottleOutPacketType.Task, true); + // If any of the packets created from this call go unacknowledged, all of the updates will be resent + OutPacket(packet, ThrottleOutPacketType.Task, true, delegate() { ResendPrimUpdates(objectUpdates.Value); }); } if (compressedUpdateBlocks.IsValueCreated) @@ -3761,10 +3798,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < blocks.Count; i++) packet.ObjectData[i] = blocks[i]; - - OutPacket(packet, ThrottleOutPacketType.Task, true); + // If any of the packets created from this call go unacknowledged, all of the updates will be resent + OutPacket(packet, ThrottleOutPacketType.Task, true, delegate() { ResendPrimUpdates(compressedUpdates.Value); }); } - + if (terseUpdateBlocks.IsValueCreated) { List blocks = terseUpdateBlocks.Value; @@ -3776,8 +3813,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < blocks.Count; i++) packet.ObjectData[i] = blocks[i]; - - OutPacket(packet, ThrottleOutPacketType.Task, true); + // If any of the packets created from this call go unacknowledged, all of the updates will be resent + OutPacket(packet, ThrottleOutPacketType.Task, true, delegate() { ResendPrimUpdates(terseUpdates.Value); }); } } @@ -3969,7 +4006,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP { SendFamilyProps = SendFamilyProps || update.SendFamilyProps; SendObjectProps = SendObjectProps || update.SendObjectProps; - Flags |= update.Flags; + // other properties may need to be updated by base class + base.Update(update); } } @@ -11363,6 +11401,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// handles splitting manually protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting) { + OutPacket(packet, throttlePacketType, doAutomaticSplitting, null); + } + + /// + /// This is the starting point for sending a simulator packet out to the client + /// + /// Packet to send + /// Throttling category for the packet + /// True to automatically split oversized + /// packets (the default), or false to disable splitting if the calling code + /// handles splitting manually + /// The method to be called in the event this packet is reliable + /// and unacknowledged. The server will provide normal resend capability if you do not + /// provide your own method. + protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method) + { if (m_debugPacketLevel > 0) { bool logPacket = true; @@ -11388,7 +11442,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_log.DebugFormat("[CLIENT]: Packet OUT {0}", packet.Type); } - m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting); + m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method); } public bool AddMoney(int debit) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index d08b25f..0848979 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -297,7 +297,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP delegate(IClientAPI client) { if (client is LLClientView) - SendPacketData(((LLClientView)client).UDPClient, data, packet.Type, category); + SendPacketData(((LLClientView)client).UDPClient, data, packet.Type, category, null); } ); } @@ -309,7 +309,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP delegate(IClientAPI client) { if (client is LLClientView) - SendPacketData(((LLClientView)client).UDPClient, data, packet.Type, category); + SendPacketData(((LLClientView)client).UDPClient, data, packet.Type, category, null); } ); } @@ -322,7 +322,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// /// - public void SendPacket(LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting) + public void SendPacket(LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method) { // CoarseLocationUpdate packets cannot be split in an automated way if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting) @@ -339,13 +339,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < packetCount; i++) { byte[] data = datas[i]; - SendPacketData(udpClient, data, packet.Type, category); + SendPacketData(udpClient, data, packet.Type, category, method); } } else { byte[] data = packet.ToBytes(); - SendPacketData(udpClient, data, packet.Type, category); + SendPacketData(udpClient, data, packet.Type, category, method); } } @@ -356,7 +356,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// /// - public void SendPacketData(LLUDPClient udpClient, byte[] data, PacketType type, ThrottleOutPacketType category) + public void SendPacketData(LLUDPClient udpClient, byte[] data, PacketType type, ThrottleOutPacketType category, UnackedPacketMethod method) { int dataLength = data.Length; bool doZerocode = (data[0] & Helpers.MSG_ZEROCODED) != 0; @@ -411,7 +411,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Queue or Send - OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); + OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category, null); + // If we were not provided a method for handling unacked, use the UDPServer default method + outgoingPacket.UnackedMethod = ((method == null) ? delegate() { ResendUnacked(outgoingPacket); } : method); // If a Linden Lab 1.23.5 client receives an update packet after a kill packet for an object, it will // continue to display the deleted object until relog. Therefore, we need to always queue a kill object @@ -445,7 +447,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP packet.Header.Reliable = false; packet.Packets = blocks.ToArray(); - SendPacket(udpClient, packet, ThrottleOutPacketType.Unknown, true); + SendPacket(udpClient, packet, ThrottleOutPacketType.Unknown, true, null); } } @@ -458,17 +460,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit pc.PingID.OldestUnacked = 0; - SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false); + SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false, null); } public void CompletePing(LLUDPClient udpClient, byte pingID) { CompletePingCheckPacket completePing = new CompletePingCheckPacket(); completePing.PingID.PingID = pingID; - SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false); + SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false, null); } - public void ResendUnacked(LLUDPClient udpClient) + public void HandleUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) return; @@ -488,31 +490,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (expiredPackets != null) { - //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); - + //m_log.Debug("[LLUDPSERVER]: Handling " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); + for (int i = 0; i < expiredPackets.Count; ++i) + expiredPackets[i].UnackedMethod(); + } + } - // Resend packets - for (int i = 0; i < expiredPackets.Count; i++) - { - OutgoingPacket outgoingPacket = expiredPackets[i]; - - //m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed", - // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); + public void ResendUnacked(OutgoingPacket outgoingPacket) + { + //m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed", + // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount); - // Set the resent flag - outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); - outgoingPacket.Category = ThrottleOutPacketType.Resend; + // Set the resent flag + outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); + outgoingPacket.Category = ThrottleOutPacketType.Resend; - // Bump up the resend count on this packet - Interlocked.Increment(ref outgoingPacket.ResendCount); + // Bump up the resend count on this packet + Interlocked.Increment(ref outgoingPacket.ResendCount); - // Requeue or resend the packet - if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, false)) - SendPacketFinal(outgoingPacket); - } - } + // Requeue or resend the packet + if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, false)) + SendPacketFinal(outgoingPacket); } public void Flush(LLUDPClient udpClient) @@ -1096,7 +1096,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (udpClient.IsConnected) { if (m_resendUnacked) - ResendUnacked(udpClient); + HandleUnacked(udpClient); if (m_sendAcks) SendAcks(udpClient); @@ -1152,7 +1152,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP nticksUnack++; watch2.Start(); - ResendUnacked(udpClient); + HandleUnacked(udpClient); watch2.Stop(); avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack); diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs index 1a1a1cb..f4f024b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs @@ -31,6 +31,7 @@ using OpenMetaverse; namespace OpenSim.Region.ClientStack.LindenUDP { + public delegate void UnackedPacketMethod(); /// /// Holds a reference to the this packet is /// destined for, along with the serialized packet data, sequence number @@ -52,6 +53,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP public int TickCount; /// Category this packet belongs to public ThrottleOutPacketType Category; + /// The delegate to be called if this packet is determined to be unacknowledged + public UnackedPacketMethod UnackedMethod; /// /// Default constructor @@ -60,11 +63,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Serialized packet data. If the flags or sequence number /// need to be updated, they will be injected directly into this binary buffer /// Throttling category for this packet - public OutgoingPacket(LLUDPClient client, UDPPacketBuffer buffer, ThrottleOutPacketType category) + public OutgoingPacket(LLUDPClient client, UDPPacketBuffer buffer, ThrottleOutPacketType category, UnackedPacketMethod method) { Client = client; Buffer = buffer; Category = category; + UnackedMethod = method; } } } -- cgit v1.1 From 82de87ce99a513debabe16af41fcb2fda3db0484 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 19 Apr 2011 11:22:04 -0700 Subject: Converted the property request queue to use the same retransmission mechanism as the entity update queues. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 75 +++++++++++++++------- 1 file changed, 52 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 14c5d6c..87b86eb 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3567,7 +3567,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// with any other updates that may be queued for the same entity. /// The original update time is used for the merged update. /// - public void ResendPrimUpdate(EntityUpdate update) + private void ResendPrimUpdate(EntityUpdate update) { // If the update exists in priority queue, it will be updated. // If it does not exist then it will be added with the current (rather than its original) priority @@ -3583,7 +3583,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// with any other updates that may be queued for the same entity. /// The original update time is used for the merged update. /// - void ResendPrimUpdates(List updates) + private void ResendPrimUpdates(List updates) { foreach (EntityUpdate update in updates) ResendPrimUpdate(update); @@ -4018,6 +4018,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false)); } + private void ResendPropertyUpdate(ObjectPropertyUpdate update) + { + uint priority = 0; + lock (m_entityProps.SyncRoot) + m_entityProps.Enqueue(priority, update); + } + + private void ResendPropertyUpdates(List updates) + { + foreach (ObjectPropertyUpdate update in updates) + ResendPropertyUpdate(update); + } + public void SendObjectPropertiesReply(ISceneEntity entity) { uint priority = 0; // time based ordering only @@ -4033,6 +4046,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP OpenSim.Framework.Lazy> objectPropertiesBlocks = new OpenSim.Framework.Lazy>(); + OpenSim.Framework.Lazy> familyUpdates = + new OpenSim.Framework.Lazy>(); + + OpenSim.Framework.Lazy> propertyUpdates = + new OpenSim.Framework.Lazy>(); + IEntityUpdate iupdate; Int32 timeinqueue; // this is just debugging code & can be dropped later @@ -4051,6 +4070,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP SceneObjectPart sop = (SceneObjectPart)update.Entity; ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags); objectFamilyBlocks.Value.Add(objPropDB); + familyUpdates.Value.Add(update); } } @@ -4061,6 +4081,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP SceneObjectPart sop = (SceneObjectPart)update.Entity; ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop); objectPropertiesBlocks.Value.Add(objPropDB); + propertyUpdates.Value.Add(update); } } @@ -4068,12 +4089,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP } - Int32 ppcnt = 0; - Int32 pbcnt = 0; + // Int32 ppcnt = 0; + // Int32 pbcnt = 0; if (objectPropertiesBlocks.IsValueCreated) { List blocks = objectPropertiesBlocks.Value; + List updates = propertyUpdates.Value; ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties); packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count]; @@ -4081,28 +4103,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP packet.ObjectData[i] = blocks[i]; packet.Header.Zerocoded = true; - OutPacket(packet, ThrottleOutPacketType.Task, true); - pbcnt += blocks.Count; - ppcnt++; + // Pass in the delegate so that if this packet needs to be resent, we send the current properties + // of the object rather than the properties when the packet was created + OutPacket(packet, ThrottleOutPacketType.Task, true, + delegate() + { + ResendPropertyUpdates(updates); + }); + + // pbcnt += blocks.Count; + // ppcnt++; } - Int32 fpcnt = 0; - Int32 fbcnt = 0; + // Int32 fpcnt = 0; + // Int32 fbcnt = 0; if (objectFamilyBlocks.IsValueCreated) { List blocks = objectFamilyBlocks.Value; - - // ObjectPropertiesFamilyPacket objPropFamilyPack = - // (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily); - // - // objPropFamilyPack.ObjectData = new ObjectPropertiesFamilyPacket.ObjectDataBlock[blocks.Count]; - // for (int i = 0; i < blocks.Count; i++) - // objPropFamilyPack.ObjectData[i] = blocks[i]; - // - // OutPacket(objPropFamilyPack, ThrottleOutPacketType.Task, true); - + List updates = familyUpdates.Value; + // one packet per object block... uggh... for (int i = 0; i < blocks.Count; i++) { @@ -4111,10 +4132,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP packet.ObjectData = blocks[i]; packet.Header.Zerocoded = true; - OutPacket(packet, ThrottleOutPacketType.Task); - fpcnt++; - fbcnt++; + // Pass in the delegate so that if this packet needs to be resent, we send the current properties + // of the object rather than the properties when the packet was created + ObjectPropertyUpdate update = updates[i]; + OutPacket(packet, ThrottleOutPacketType.Task, true, + delegate() + { + ResendPropertyUpdate(update); + }); + + // fpcnt++; + // fbcnt++; } } @@ -4151,7 +4180,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return block; } - + private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop) { //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties); -- cgit v1.1 From 2b737c9cc2e4a4ef3520d80225381a010bd1dc80 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 20 Apr 2011 16:23:33 -0700 Subject: Adds the first pass at an adaptive throttle to slow start new clients. If the sent packets are ack'ed successfully the throttle will open quickly up to the maximum specified by the client and/or the sims client throttle. This still needs a lot of adjustment to get the rates correct. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 4 + .../Region/ClientStack/LindenUDP/LLUDPClient.cs | 9 ++- .../Region/ClientStack/LindenUDP/TokenBucket.cs | 92 ++++++++++++++++++---- .../LindenUDP/UnackedPacketCollection.cs | 8 ++ 4 files changed, 95 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 87b86eb..1108863 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3585,6 +3585,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private void ResendPrimUpdates(List updates) { + // m_log.WarnFormat("[CLIENT] resending prim update {0}",updates[0].UpdateTime); + foreach (EntityUpdate update in updates) ResendPrimUpdate(update); } @@ -4027,6 +4029,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void ResendPropertyUpdates(List updates) { + // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime); + foreach (ObjectPropertyUpdate update in updates) ResendPropertyUpdate(update); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 7be8a0a..20bfec8 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs @@ -135,7 +135,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP private int m_nextOnQueueEmpty = 1; /// Throttle bucket for this agent's connection - private readonly TokenBucket m_throttleClient; + private readonly AdaptiveTokenBucket m_throttleClient; + public AdaptiveTokenBucket FlowThrottle + { + get { return m_throttleClient; } + } + /// Throttle bucket for this agent's connection private readonly TokenBucket m_throttleCategory; /// Throttle buckets for each packet category @@ -176,7 +181,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_maxRTO = maxRTO; // Create a token bucket throttle for this client that has the scene token bucket as a parent - m_throttleClient = new TokenBucket(parentThrottle, rates.TotalLimit); + m_throttleClient = new AdaptiveTokenBucket(parentThrottle, rates.TotalLimit); // Create a token bucket throttle for the total categary with the client bucket as a throttle m_throttleCategory = new TokenBucket(m_throttleClient, rates.TotalLimit); // Create an array of token buckets for this clients different throttle categories diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index 07b0a1d..4ee6d3a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -48,31 +48,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Number of ticks (ms) per quantum, drip rate and max burst /// are defined over this interval. /// - private const Int32 m_ticksPerQuantum = 1000; + protected const Int32 m_ticksPerQuantum = 1000; /// /// This is the number of quantums worth of packets that can /// be accommodated during a burst /// - private const Double m_quantumsPerBurst = 1.5; + protected const Double m_quantumsPerBurst = 1.5; /// /// - private const Int32 m_minimumDripRate = 1400; + protected const Int32 m_minimumDripRate = 1400; /// Time of the last drip, in system ticks - private Int32 m_lastDrip; + protected Int32 m_lastDrip; /// /// The number of bytes that can be sent at this moment. This is the /// current number of tokens in the bucket /// - private Int64 m_tokenCount; + protected Int64 m_tokenCount; /// /// Map of children buckets and their requested maximum burst rate /// - private Dictionary m_children = new Dictionary(); + protected Dictionary m_children = new Dictionary(); #region Properties @@ -81,7 +81,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// parent. The parent bucket will limit the aggregate bandwidth of all /// of its children buckets /// - private TokenBucket m_parent; + protected TokenBucket m_parent; public TokenBucket Parent { get { return m_parent; } @@ -93,7 +93,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// of tokens that can accumulate in the bucket at any one time. This /// also sets the total request for leaf nodes /// - private Int64 m_burstRate; + protected Int64 m_burstRate; public Int64 RequestedBurstRate { get { return m_burstRate; } @@ -118,8 +118,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Tokens are added to the bucket any time /// is called, at the granularity of /// the system tick interval (typically around 15-22ms) - private Int64 m_dripRate; - public Int64 RequestedDripRate + protected Int64 m_dripRate; + public virtual Int64 RequestedDripRate { get { return (m_dripRate == 0 ? m_totalDripRequest : m_dripRate); } set { @@ -131,7 +131,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - public Int64 DripRate + public virtual Int64 DripRate { get { if (m_parent == null) @@ -149,7 +149,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// The current total of the requested maximum burst rates of /// this bucket's children buckets. /// - private Int64 m_totalDripRequest; + protected Int64 m_totalDripRequest; public Int64 TotalDripRequest { get { return m_totalDripRequest; } @@ -189,7 +189,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// hierarchy. However, if any of the parents is over-booked, then /// the modifier will be less than 1. /// - private double DripRateModifier() + protected double DripRateModifier() { Int64 driprate = DripRate; return driprate >= TotalDripRequest ? 1.0 : (double)driprate / (double)TotalDripRequest; @@ -197,7 +197,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// - private double BurstRateModifier() + protected double BurstRateModifier() { // for now... burst rate is always m_quantumsPerBurst (constant) // larger than drip rate so the ratio of burst requests is the @@ -268,7 +268,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Deposit tokens into the bucket from a child bucket that did /// not use all of its available tokens /// - private void Deposit(Int64 count) + protected void Deposit(Int64 count) { m_tokenCount += count; @@ -285,7 +285,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// call to Drip /// /// True if tokens were added to the bucket, otherwise false - private void Drip() + protected void Drip() { // This should never happen... means we are a leaf node and were created // with no drip rate... @@ -310,4 +310,64 @@ namespace OpenSim.Region.ClientStack.LindenUDP Deposit(deltaMS * DripRate / m_ticksPerQuantum); } } + + public class AdaptiveTokenBucket : TokenBucket + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + // + // The minimum rate for flow control. + // + protected const Int64 m_minimumFlow = m_minimumDripRate * 10; + + // + // The maximum rate for flow control. Drip rate can never be + // greater than this. + // + protected Int64 m_maxDripRate = 0; + protected Int64 MaxDripRate + { + get { return (m_maxDripRate == 0 ? m_totalDripRequest : m_maxDripRate); } + set { m_maxDripRate = (value == 0 ? 0 : Math.Max(value,m_minimumFlow)); } + } + + // + // + // + public virtual Int64 AdjustedDripRate + { + get { return m_dripRate; } + set { + m_dripRate = OpenSim.Framework.Util.Clamp(value,m_minimumFlow,MaxDripRate); + m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst); + if (m_parent != null) + m_parent.RegisterRequest(this,m_dripRate); + } + } + + // + // + // + public AdaptiveTokenBucket(TokenBucket parent, Int64 maxDripRate) : base(parent,m_minimumFlow) + { + MaxDripRate = maxDripRate; + } + + // + // + // + public void ExpirePackets(Int32 count) + { + // m_log.WarnFormat("[ADAPTIVEBUCKET] drop {0} by {1} expired packets",AdjustedDripRate,count); + AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,count)); + } + + // + // + // + public void AcknowledgePackets(Int32 count) + { + AdjustedDripRate = AdjustedDripRate + count; + } + } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs index d195110..b170964 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs @@ -130,6 +130,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP // is actually sent out again packet.TickCount = 0; + // As with other network applications, assume that an expired packet is + // an indication of some network problem, slow transmission + packet.Client.FlowThrottle.ExpirePackets(1); + expiredPackets.Add(packet); } } @@ -157,6 +161,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP { m_packets.Remove(pendingRemove.SequenceNumber); + // As with other network applications, assume that an acknowledged packet is an + // indication that the network can handle a little more load, speed up the transmission + ackedPacket.Client.FlowThrottle.AcknowledgePackets(ackedPacket.Buffer.DataLength); + // Update stats Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); -- cgit v1.1 From 7759bda833c03f4c29500dce32b835a7aef8285b Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 20 Apr 2011 21:58:49 -0700 Subject: Added an "immediate" queue to the priority queue. This is per Melanie's very good suggestion. The immediate queue is serviced completely before all others, making it a very good place to put avatar updates & attachments. Moved the priority queue out of the LLUDP directory and into the framework. It is now a fairly general utility. --- .../Region/ClientStack/LindenUDP/PriorityQueue.cs | 245 --------------------- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 4 +- 2 files changed, 2 insertions(+), 247 deletions(-) delete mode 100644 OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs deleted file mode 100644 index b62ec07..0000000 --- a/OpenSim/Region/ClientStack/LindenUDP/PriorityQueue.cs +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; - -using OpenSim.Framework; -using OpenSim.Framework.Client; -using log4net; - -namespace OpenSim.Region.ClientStack.LindenUDP -{ - public class PriorityQueue - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - internal delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity); - - // Heap[0] for self updates - // Heap[1..12] for entity updates - - internal const uint m_numberOfQueues = 12; - - private MinHeap[] m_heaps = new MinHeap[m_numberOfQueues]; - private Dictionary m_lookupTable; - private uint m_nextQueue = 0; - private UInt64 m_nextRequest = 0; - - private object m_syncRoot = new object(); - public object SyncRoot { - get { return this.m_syncRoot; } - } - - internal PriorityQueue() : this(MinHeap.DEFAULT_CAPACITY) { } - - internal PriorityQueue(int capacity) - { - m_lookupTable = new Dictionary(capacity); - - for (int i = 0; i < m_heaps.Length; ++i) - m_heaps[i] = new MinHeap(capacity); - } - - internal int Count - { - get - { - int count = 0; - for (int i = 0; i < m_heaps.Length; ++i) - count += m_heaps[i].Count; - return count; - } - } - - public bool Enqueue(uint pqueue, IEntityUpdate value) - { - LookupItem lookup; - - uint localid = value.Entity.LocalId; - UInt64 entry = m_nextRequest++; - if (m_lookupTable.TryGetValue(localid, out lookup)) - { - entry = lookup.Heap[lookup.Handle].EntryOrder; - value.Update(lookup.Heap[lookup.Handle].Value); - lookup.Heap.Remove(lookup.Handle); - } - - pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); - lookup.Heap = m_heaps[pqueue]; - lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle); - m_lookupTable[localid] = lookup; - - return true; - } - - internal bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue) - { - for (int i = 0; i < m_numberOfQueues; ++i) - { - // To get the fair queing, we cycle through each of the - // queues when finding an element to dequeue, this code - // assumes that the distribution of updates in the queues - // is polynomial, probably quadractic (eg distance of PI * R^2) - uint h = (uint)((m_nextQueue + i) % m_numberOfQueues); - if (m_heaps[h].Count > 0) - { - m_nextQueue = (uint)((h + 1) % m_numberOfQueues); - - MinHeapItem item = m_heaps[h].RemoveMin(); - m_lookupTable.Remove(item.Value.Entity.LocalId); - timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); - value = item.Value; - - return true; - } - } - - timeinqueue = 0; - value = default(IEntityUpdate); - return false; - } - - internal void Reprioritize(UpdatePriorityHandler handler) - { - MinHeapItem item; - foreach (LookupItem lookup in new List(this.m_lookupTable.Values)) - { - if (lookup.Heap.TryGetValue(lookup.Handle, out item)) - { - uint pqueue = item.PriorityQueue; - uint localid = item.Value.Entity.LocalId; - - if (handler(ref pqueue, item.Value.Entity)) - { - // unless the priority queue has changed, there is no need to modify - // the entry - pqueue = Util.Clamp(pqueue, 0, m_numberOfQueues - 1); - if (pqueue != item.PriorityQueue) - { - lookup.Heap.Remove(lookup.Handle); - - LookupItem litem = lookup; - litem.Heap = m_heaps[pqueue]; - litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle); - m_lookupTable[localid] = litem; - } - } - else - { - // m_log.WarnFormat("[PQUEUE]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID); - lookup.Heap.Remove(lookup.Handle); - this.m_lookupTable.Remove(localid); - } - } - } - } - - public override string ToString() - { - string s = ""; - for (int i = 0; i < m_numberOfQueues; i++) - { - if (s != "") s += ","; - s += m_heaps[i].Count.ToString(); - } - return s; - } - -#region MinHeapItem - private struct MinHeapItem : IComparable - { - private IEntityUpdate value; - internal IEntityUpdate Value { - get { - return this.value; - } - } - - private uint pqueue; - internal uint PriorityQueue { - get { - return this.pqueue; - } - } - - private Int32 entrytime; - internal Int32 EntryTime { - get { - return this.entrytime; - } - } - - private UInt64 entryorder; - internal UInt64 EntryOrder - { - get { - return this.entryorder; - } - } - - internal MinHeapItem(uint pqueue, MinHeapItem other) - { - this.entrytime = other.entrytime; - this.entryorder = other.entryorder; - this.value = other.value; - this.pqueue = pqueue; - } - - internal MinHeapItem(uint pqueue, UInt64 entryorder, IEntityUpdate value) - { - this.entrytime = Util.EnvironmentTickCount(); - this.entryorder = entryorder; - this.value = value; - this.pqueue = pqueue; - } - - public override string ToString() - { - return String.Format("[{0},{1},{2}]",pqueue,entryorder,value.Entity.LocalId); - } - - public int CompareTo(MinHeapItem other) - { - // I'm assuming that the root part of an SOG is added to the update queue - // before the component parts - return Comparer.Default.Compare(this.EntryOrder, other.EntryOrder); - } - } -#endregion - -#region LookupItem - private struct LookupItem - { - internal MinHeap Heap; - internal IHandle Handle; - } -#endregion - } -} diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index e3ed905..2e80156 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Scenes // If this is an update for our own avatar give it the highest priority if (client.AgentId == entity.UUID) - return 0; + return PriorityQueue.ImmediateQueue; uint priority; @@ -172,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.WarnFormat("[PRIORITIZER] attempt to use agent {0} not in the scene",client.AgentId); // throw new InvalidOperationException("Prioritization agent not defined"); - return Int32.MaxValue; + return PriorityQueue.NumberOfQueues - 1; } // Use group position for child prims, since we are putting child prims in -- cgit v1.1 From b5ab33b5e190e79789df3f44b24959fd229a8c6d Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Wed, 20 Apr 2011 23:08:51 -0700 Subject: bug fix. Now when an unacked update packet is handled through ResendPrimUpdates, it is removed from the UnackedPacketCollection. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 34 +++++++++++++--------- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 4 +-- .../Region/ClientStack/LindenUDP/OutgoingPacket.cs | 3 +- 3 files changed, 25 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 1108863..1e8bbb8 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3583,10 +3583,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// with any other updates that may be queued for the same entity. /// The original update time is used for the merged update. /// - private void ResendPrimUpdates(List updates) + private void ResendPrimUpdates(List updates, OutgoingPacket oPacket) { // m_log.WarnFormat("[CLIENT] resending prim update {0}",updates[0].UpdateTime); - + + // Remove the update packet from the list of packets waiting for acknowledgement + // because we are requeuing the list of updates. They will be resent in new packets + // with the most recent state and priority. + m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber, 0, true); foreach (EntityUpdate update in updates) ResendPrimUpdate(update); } @@ -3771,7 +3775,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < blocks.Count; i++) packet.ObjectData[i] = blocks[i]; // If any of the packets created from this call go unacknowledged, all of the updates will be resent - OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate() { ResendPrimUpdates(terseAgentUpdates.Value); }); + OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); }); } if (objectUpdateBlocks.IsValueCreated) @@ -3786,7 +3790,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < blocks.Count; i++) packet.ObjectData[i] = blocks[i]; // If any of the packets created from this call go unacknowledged, all of the updates will be resent - OutPacket(packet, ThrottleOutPacketType.Task, true, delegate() { ResendPrimUpdates(objectUpdates.Value); }); + OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); }); } if (compressedUpdateBlocks.IsValueCreated) @@ -3801,7 +3805,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < blocks.Count; i++) packet.ObjectData[i] = blocks[i]; // If any of the packets created from this call go unacknowledged, all of the updates will be resent - OutPacket(packet, ThrottleOutPacketType.Task, true, delegate() { ResendPrimUpdates(compressedUpdates.Value); }); + OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); }); } if (terseUpdateBlocks.IsValueCreated) @@ -3816,7 +3820,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < blocks.Count; i++) packet.ObjectData[i] = blocks[i]; // If any of the packets created from this call go unacknowledged, all of the updates will be resent - OutPacket(packet, ThrottleOutPacketType.Task, true, delegate() { ResendPrimUpdates(terseUpdates.Value); }); + OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); }); } } @@ -4027,10 +4031,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_entityProps.Enqueue(priority, update); } - private void ResendPropertyUpdates(List updates) + private void ResendPropertyUpdates(List updates, OutgoingPacket oPacket) { // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime); + // Remove the update packet from the list of packets waiting for acknowledgement + // because we are requeuing the list of updates. They will be resent in new packets + // with the most recent state. + m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber, 0, true); foreach (ObjectPropertyUpdate update in updates) ResendPropertyUpdate(update); } @@ -4111,9 +4119,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Pass in the delegate so that if this packet needs to be resent, we send the current properties // of the object rather than the properties when the packet was created OutPacket(packet, ThrottleOutPacketType.Task, true, - delegate() + delegate(OutgoingPacket oPacket) { - ResendPropertyUpdates(updates); + ResendPropertyUpdates(updates, oPacket); }); // pbcnt += blocks.Count; @@ -4126,7 +4134,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (objectFamilyBlocks.IsValueCreated) { List blocks = objectFamilyBlocks.Value; - List updates = familyUpdates.Value; // one packet per object block... uggh... for (int i = 0; i < blocks.Count; i++) @@ -4139,11 +4146,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Pass in the delegate so that if this packet needs to be resent, we send the current properties // of the object rather than the properties when the packet was created - ObjectPropertyUpdate update = updates[i]; + List updates = new List(); + updates.Add(familyUpdates.Value[i]); OutPacket(packet, ThrottleOutPacketType.Task, true, - delegate() + delegate(OutgoingPacket oPacket) { - ResendPropertyUpdate(update); + ResendPropertyUpdates(updates, oPacket); }); // fpcnt++; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 0848979..bd58ddc 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -413,7 +413,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category, null); // If we were not provided a method for handling unacked, use the UDPServer default method - outgoingPacket.UnackedMethod = ((method == null) ? delegate() { ResendUnacked(outgoingPacket); } : method); + outgoingPacket.UnackedMethod = ((method == null) ? delegate(OutgoingPacket oPacket) { ResendUnacked(oPacket); } : method); // If a Linden Lab 1.23.5 client receives an update packet after a kill packet for an object, it will // continue to display the deleted object until relog. Therefore, we need to always queue a kill object @@ -494,7 +494,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); for (int i = 0; i < expiredPackets.Count; ++i) - expiredPackets[i].UnackedMethod(); + expiredPackets[i].UnackedMethod(expiredPackets[i]); } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs index f4f024b..76c6c14 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs @@ -31,7 +31,8 @@ using OpenMetaverse; namespace OpenSim.Region.ClientStack.LindenUDP { - public delegate void UnackedPacketMethod(); + + public delegate void UnackedPacketMethod(OutgoingPacket oPacket); /// /// Holds a reference to the this packet is /// destined for, along with the serialized packet data, sequence number -- cgit v1.1 From 3640d0204f77dff3b1c4bd50229b60a49d2745e5 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 21 Apr 2011 01:51:08 -0700 Subject: Added ability to remove unacked packet from UnackedPacketCollection without an acknowledgement from the network. This prevents RTT and throttles from being updated as they would when an ACK is actually received. Also fixed stats logging for unacked bytes and resent packets in this case. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 12 ++++++++-- .../LindenUDP/UnackedPacketCollection.cs | 28 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 1e8bbb8..6129e10 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3590,7 +3590,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Remove the update packet from the list of packets waiting for acknowledgement // because we are requeuing the list of updates. They will be resent in new packets // with the most recent state and priority. - m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber, 0, true); + m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber); + + // Count this as a resent packet since we are going to requeue all of the updates contained in it + Interlocked.Increment(ref m_udpClient.PacketsResent); + foreach (EntityUpdate update in updates) ResendPrimUpdate(update); } @@ -4038,7 +4042,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Remove the update packet from the list of packets waiting for acknowledgement // because we are requeuing the list of updates. They will be resent in new packets // with the most recent state. - m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber, 0, true); + m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber); + + // Count this as a resent packet since we are going to requeue all of the updates contained in it + Interlocked.Increment(ref m_udpClient.PacketsResent); + foreach (ObjectPropertyUpdate update in updates) ResendPropertyUpdate(update); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs index b170964..90a87fa 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs @@ -83,6 +83,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// Marks a packet as acknowledged + /// This method is used when an acknowledgement is received from the network for a previously + /// sent packet. Effects of removal this way are to update unacked byte count, adjust RTT + /// and increase throttle to the coresponding client. /// /// Sequence number of the packet to /// acknowledge @@ -95,6 +98,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP } /// + /// Marks a packet as no longer needing acknowledgement without a received acknowledgement. + /// This method is called when a packet expires and we no longer need an acknowledgement. + /// When some reliable packet types expire, they are handled in a way other than simply + /// resending them. The only effect of removal this way is to update unacked byte count. + /// + /// Sequence number of the packet to + /// acknowledge + /// The packet is removed from the collection immediately. + /// This function is not threadsafe. It must be called by the thread calling GetExpiredPackets. + public void Remove(uint sequenceNumber) + { + OutgoingPacket removedPacket; + if (m_packets.TryGetValue(sequenceNumber, out removedPacket)) + { + if (removedPacket != null) + { + m_packets.Remove(sequenceNumber); + + // Update stats + Interlocked.Add(ref removedPacket.Client.UnackedBytes, -removedPacket.Buffer.DataLength); + } + } + } + + /// /// Returns a list of all of the packets with a TickCount older than /// the specified timeout /// -- cgit v1.1 From 13d6e05d5a346dcb9dbaec29af37ee63be790acb Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 21 Apr 2011 23:03:38 +0100 Subject: Implement agent limits --- OpenSim/Region/Framework/Scenes/Scene.cs | 20 ++++++++++++++++++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 5 +++++ 2 files changed, 25 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fdd5205..01de824 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3665,6 +3665,15 @@ namespace OpenSim.Region.Framework.Scenes return false; } + int num = m_sceneGraph.GetNumberOfScenePresences(); + + if (num >= RegionInfo.RegionSettings.AgentLimit) + { + if (!Permissions.IsAdministrator(cAgentData.AgentID)) + return false; + } + + ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); if (childAgentUpdate != null) @@ -4966,6 +4975,17 @@ namespace OpenSim.Region.Framework.Scenes // child agent creation, thereby emulating the SL behavior. public bool QueryAccess(UUID agentID, Vector3 position, out string reason) { + int num = m_sceneGraph.GetNumberOfScenePresences(); + + if (num >= RegionInfo.RegionSettings.AgentLimit) + { + if (!Permissions.IsAdministrator(agentID)) + { + reason = "The region is full"; + return false; + } + } + reason = String.Empty; return true; } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 72f0402..fc31b65 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -800,6 +800,11 @@ namespace OpenSim.Region.Framework.Scenes return m_scenePresenceArray; } + public int GetNumberOfScenePresences() + { + return m_scenePresenceArray.Count; + } + /// /// Request a scene presence by UUID. Fast, indexed lookup. /// -- cgit v1.1 From 7f28dd4b3195e020eed51fa1229083123935125b Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 21 Apr 2011 15:40:32 -0700 Subject: Refactor UnackedPacketCollection so ProcessQueues will handle Adds, Acks, and Removes in that order. --- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 4 +- .../LindenUDP/UnackedPacketCollection.cs | 56 ++++++++++++---------- 2 files changed, 34 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index bd58ddc..aff90c5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -672,7 +672,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (packet.Header.AppendedAcks && packet.Header.AckList != null) { for (int i = 0; i < packet.Header.AckList.Length; i++) - udpClient.NeedAcks.Remove(packet.Header.AckList[i], now, packet.Header.Resent); + udpClient.NeedAcks.Acknowledge(packet.Header.AckList[i], now, packet.Header.Resent); } // Handle PacketAck packets @@ -681,7 +681,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP PacketAckPacket ackPacket = (PacketAckPacket)packet; for (int i = 0; i < ackPacket.Packets.Length; i++) - udpClient.NeedAcks.Remove(ackPacket.Packets[i].ID, now, packet.Header.Resent); + udpClient.NeedAcks.Acknowledge(ackPacket.Packets[i].ID, now, packet.Header.Resent); // We don't need to do anything else with PacketAck packets return; diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs index 90a87fa..793aefe 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs @@ -65,7 +65,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Holds packets that need to be added to the unacknowledged list private LocklessQueue m_pendingAdds = new LocklessQueue(); /// Holds information about pending acknowledgements - private LocklessQueue m_pendingRemoves = new LocklessQueue(); + private LocklessQueue m_pendingAcknowledgements = new LocklessQueue(); + /// Holds information about pending removals + private LocklessQueue m_pendingRemoves = new LocklessQueue(); /// /// Add an unacked packet to the collection @@ -92,9 +94,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Current value of Environment.TickCount /// This does not immediately acknowledge the packet, it only /// queues the ack so it can be handled in a thread-safe way later - public void Remove(uint sequenceNumber, int currentTime, bool fromResend) + public void Acknowledge(uint sequenceNumber, int currentTime, bool fromResend) { - m_pendingRemoves.Enqueue(new PendingAck(sequenceNumber, currentTime, fromResend)); + m_pendingAcknowledgements.Enqueue(new PendingAck(sequenceNumber, currentTime, fromResend)); } /// @@ -105,21 +107,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// Sequence number of the packet to /// acknowledge - /// The packet is removed from the collection immediately. - /// This function is not threadsafe. It must be called by the thread calling GetExpiredPackets. + /// The does not immediately remove the packet, it only queues the removal + /// so it can be handled in a thread safe way later public void Remove(uint sequenceNumber) { - OutgoingPacket removedPacket; - if (m_packets.TryGetValue(sequenceNumber, out removedPacket)) - { - if (removedPacket != null) - { - m_packets.Remove(sequenceNumber); - - // Update stats - Interlocked.Add(ref removedPacket.Client.UnackedBytes, -removedPacket.Buffer.DataLength); - } - } + m_pendingRemoves.Enqueue(sequenceNumber); } /// @@ -179,15 +171,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_packets[pendingAdd.SequenceNumber] = pendingAdd; // Process all the pending removes, including updating statistics and round-trip times - PendingAck pendingRemove; - OutgoingPacket ackedPacket; - while (m_pendingRemoves.TryDequeue(out pendingRemove)) + PendingAck pendingAcknowledgement; + while (m_pendingAcknowledgements.TryDequeue(out pendingAcknowledgement)) { - if (m_packets.TryGetValue(pendingRemove.SequenceNumber, out ackedPacket)) + OutgoingPacket ackedPacket; + if (m_packets.TryGetValue(pendingAcknowledgement.SequenceNumber, out ackedPacket)) { if (ackedPacket != null) { - m_packets.Remove(pendingRemove.SequenceNumber); + m_packets.Remove(pendingAcknowledgement.SequenceNumber); // As with other network applications, assume that an acknowledged packet is an // indication that the network can handle a little more load, speed up the transmission @@ -196,16 +188,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Update stats Interlocked.Add(ref ackedPacket.Client.UnackedBytes, -ackedPacket.Buffer.DataLength); - if (!pendingRemove.FromResend) + if (!pendingAcknowledgement.FromResend) { // Calculate the round-trip time for this packet and its ACK - int rtt = pendingRemove.RemoveTime - ackedPacket.TickCount; + int rtt = pendingAcknowledgement.RemoveTime - ackedPacket.TickCount; if (rtt > 0) ackedPacket.Client.UpdateRoundTrip(rtt); } } } } + + uint pendingRemove; + while(m_pendingRemoves.TryDequeue(out pendingRemove)) + { + OutgoingPacket removedPacket; + if (m_packets.TryGetValue(pendingRemove, out removedPacket)) + { + if (removedPacket != null) + { + m_packets.Remove(pendingRemove); + + // Update stats + Interlocked.Add(ref removedPacket.Client.UnackedBytes, -removedPacket.Buffer.DataLength); + } + } + } } } -} \ No newline at end of file +} -- cgit v1.1 From c5159ad8d00e5b2dc19eb100ec2e74a7a605e139 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Thu, 21 Apr 2011 15:40:38 -0700 Subject: Add some locking on the child list for the token bucket hiearchy. A few other cosmetic changes. --- .../Region/ClientStack/LindenUDP/TokenBucket.cs | 37 +++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index 4ee6d3a..8ce64d5 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -29,6 +29,8 @@ using System; using System.Collections; using System.Collections.Generic; using System.Reflection; +using OpenSim.Framework; + using log4net; namespace OpenSim.Region.ClientStack.LindenUDP @@ -177,7 +179,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP RequestedDripRate = dripRate; // TotalDripRequest = dripRate; // this will be overwritten when a child node registers // MaxBurst = (Int64)((double)dripRate * m_quantumsPerBurst); - m_lastDrip = Environment.TickCount & Int32.MaxValue; + m_lastDrip = Util.EnvironmentTickCount(); } #endregion Constructor @@ -211,12 +213,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public void RegisterRequest(TokenBucket child, Int64 request) { - m_children[child] = request; - // m_totalDripRequest = m_children.Values.Sum(); + lock (m_children) + { + m_children[child] = request; + // m_totalDripRequest = m_children.Values.Sum(); - m_totalDripRequest = 0; - foreach (KeyValuePair cref in m_children) - m_totalDripRequest += cref.Value; + m_totalDripRequest = 0; + foreach (KeyValuePair cref in m_children) + m_totalDripRequest += cref.Value; + } // Pass the new values up to the parent if (m_parent != null) @@ -229,12 +234,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public void UnregisterRequest(TokenBucket child) { - m_children.Remove(child); - // m_totalDripRequest = m_children.Values.Sum(); + lock (m_children) + { + m_children.Remove(child); + // m_totalDripRequest = m_children.Values.Sum(); - m_totalDripRequest = 0; - foreach (KeyValuePair cref in m_children) - m_totalDripRequest += cref.Value; + m_totalDripRequest = 0; + foreach (KeyValuePair cref in m_children) + m_totalDripRequest += cref.Value; + } + // Pass the new values up to the parent if (m_parent != null) @@ -297,10 +306,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Determine the interval over which we are adding tokens, never add // more than a single quantum of tokens - Int32 now = Environment.TickCount & Int32.MaxValue; - Int32 deltaMS = Math.Min(now - m_lastDrip, m_ticksPerQuantum); - - m_lastDrip = now; + Int32 deltaMS = Math.Min(Util.EnvironmentTickCountSubtract(m_lastDrip), m_ticksPerQuantum); + m_lastDrip = Util.EnvironmentTickCount(); // This can be 0 in the very unusual case that the timer wrapped // It can be 0 if we try add tokens at a sub-tick rate -- cgit v1.1 From e0002f6b64e7aeb29de9f1db92ed39d3d1df578c Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 21 Apr 2011 19:04:41 -0400 Subject: some mesh config asthetics --- OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs | 2 +- .../Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs index deec444..fc1ddef 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetMeshModule.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets if (meshConfig == null) return; - m_enabled = meshConfig.GetBoolean("ColladaMesh", true); + m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); } public void AddRegion(Scene pScene) diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs index d651cb2..3d4c7b7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/NewFileAgentInventoryVariablePriceModule.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Assets if (meshConfig == null) return; - m_enabled = meshConfig.GetBoolean("ColladaMesh", true); + m_enabled = meshConfig.GetBoolean("AllowMeshUpload", true); } public void AddRegion(Scene pScene) -- cgit v1.1 From 3534f4492ae747baff492f4bc10bf06994ee1bc6 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 22 Apr 2011 14:01:12 -0700 Subject: Various clean ups. Removed some debugging code. Added a new "show pqueues" command to look at the entity update priority queue. Added a "name" parameter to show queues, show pqueues and show throttles to look at data for a specific user. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 5 + .../Region/ClientStack/LindenUDP/LLUDPClient.cs | 24 +---- .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 103 ++++++++++++++++++++- 3 files changed, 107 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 6129e10..32a075a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -385,6 +385,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); } /// + /// Entity update queues + /// + public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } } + + /// /// First name of the agent/avatar represented by the client /// public string FirstName { get { return m_firstName; } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 20bfec8..103ec66 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs @@ -228,26 +228,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Information about the client connection public ClientInfo GetClientInfo() { -/// - TokenBucket tb; - - tb = m_throttleClient.Parent; - m_log.WarnFormat("[TOKENS] {3}: Actual={0},Request={1},TotalRequest={2}",tb.DripRate,tb.RequestedDripRate,tb.TotalDripRequest,"ROOT"); - - tb = m_throttleClient; - m_log.WarnFormat("[TOKENS] {3}: Actual={0},Request={1},TotalRequest={2}",tb.DripRate,tb.RequestedDripRate,tb.TotalDripRequest," CLIENT"); - - tb = m_throttleCategory; - m_log.WarnFormat("[TOKENS] {3}: Actual={0},Request={1},TotalRequest={2}",tb.DripRate,tb.RequestedDripRate,tb.TotalDripRequest," CATEGORY"); - - for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) - { - tb = m_throttleCategories[i]; - m_log.WarnFormat("[TOKENS] {4} <{0}:{1}>: Actual={2},Requested={3}",AgentID,i,tb.DripRate,tb.RequestedDripRate," BUCKET"); - } - -/// - // TODO: This data structure is wrong in so many ways. Locking and copying the entire lists // of pending and needed ACKs for every client every time some method wants information about // this connection is a recipe for poor performance @@ -259,12 +239,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP info.landThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Land].DripRate; info.windThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate; info.cloudThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate; - // info.taskThrottle = m_throttleCategories[(int)ThrottleOutPacketType.State].DripRate + m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate; info.taskThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate; info.assetThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate; info.textureThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate; - info.totalThrottle = info.resendThrottle + info.landThrottle + info.windThrottle + info.cloudThrottle + - info.taskThrottle + info.assetThrottle + info.textureThrottle; + info.totalThrottle = (int)m_throttleCategory.DripRate; return info; } diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 6a24cc1..ddbc079 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -82,6 +82,14 @@ namespace OpenSim.Region.CoreModules.UDP.Linden m_scenes[scene.RegionInfo.RegionID] = scene; scene.AddCommand( + this, "show pqueues", + "show pqueues [full]", + "Show priority queue data for each client", + "Without the 'full' option, only root agents are shown." + + " With the 'full' option child agents are also shown.", + ShowPQueuesReport); + + scene.AddCommand( this, "show queues", "show queues [full]", "Show queue data for each client", @@ -119,6 +127,11 @@ namespace OpenSim.Region.CoreModules.UDP.Linden // m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); } + protected void ShowPQueuesReport(string module, string[] cmd) + { + MainConsole.Instance.Output(GetPQueuesReport(cmd)); + } + protected void ShowQueuesReport(string module, string[] cmd) { MainConsole.Instance.Output(GetQueuesReport(cmd)); @@ -155,6 +168,80 @@ namespace OpenSim.Region.CoreModules.UDP.Linden ""); } + + /// + /// Generate UDP Queue data report for each client + /// + /// + /// + protected string GetPQueuesReport(string[] showParams) + { + bool showChildren = false; + string pname = ""; + + if (showParams.Length > 2 && showParams[2] == "full") + showChildren = true; + else if (showParams.Length > 3) + pname = showParams[2] + " " + showParams[3]; + + StringBuilder report = new StringBuilder(); + + int columnPadding = 2; + int maxNameLength = 18; + int maxRegionNameLength = 14; + int maxTypeLength = 4; + int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding; + + report.Append(GetColumnEntry("User", maxNameLength, columnPadding)); + report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding)); + report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); + + report.AppendFormat( + "{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7} {10,7} {11,7}\n", + "Pri 0", + "Pri 1", + "Pri 2", + "Pri 3", + "Pri 4", + "Pri 5", + "Pri 6", + "Pri 7", + "Pri 8", + "Pri 9", + "Pri 10", + "Pri 11"); + + lock (m_scenes) + { + foreach (Scene scene in m_scenes.Values) + { + scene.ForEachClient( + delegate(IClientAPI client) + { + if (client is LLClientView) + { + bool isChild = scene.PresenceChildStatus(client.AgentId); + if (isChild && !showChildren) + return; + + string name = client.Name; + if (pname != "" && name != pname) + return; + + string regionName = scene.RegionInfo.RegionName; + + report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); + report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); + report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); + report.AppendLine(((LLClientView)client).EntityUpdateQueue.ToString()); + } + }); + } + } + + return report.ToString(); + } + /// /// Generate UDP Queue data report for each client /// @@ -163,10 +250,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden protected string GetQueuesReport(string[] showParams) { bool showChildren = false; + string pname = ""; if (showParams.Length > 2 && showParams[2] == "full") showChildren = true; - + else if (showParams.Length > 3) + pname = showParams[2] + " " + showParams[3]; + StringBuilder report = new StringBuilder(); int columnPadding = 2; @@ -224,6 +314,9 @@ namespace OpenSim.Region.CoreModules.UDP.Linden return; string name = client.Name; + if (pname != "" && name != pname) + return; + string regionName = scene.RegionInfo.RegionName; report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); @@ -249,10 +342,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden protected string GetThrottlesReport(string[] showParams) { bool showChildren = false; + string pname = ""; if (showParams.Length > 2 && showParams[2] == "full") showChildren = true; - + else if (showParams.Length > 3) + pname = showParams[2] + " " + showParams[3]; + StringBuilder report = new StringBuilder(); int columnPadding = 2; @@ -314,6 +410,9 @@ namespace OpenSim.Region.CoreModules.UDP.Linden return; string name = client.Name; + if (pname != "" && name != pname) + return; + string regionName = scene.RegionInfo.RegionName; LLUDPClient llUdpClient = llClient.UDPClient; -- cgit v1.1 From 08e58e7ca6602782e1727bed9ade89fa42e9b55b Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 22 Apr 2011 14:02:34 -0700 Subject: Set the initial rate for the adaptive throttle to 160Kpbs or about 15 packets per second. --- OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index 8ce64d5..677d3d1 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -322,10 +322,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - // - // The minimum rate for flow control. - // - protected const Int64 m_minimumFlow = m_minimumDripRate * 10; + /// + /// The minimum rate for flow control. Minimum drip rate is one + /// packet per second. Open the throttle to 15 packets per second + /// or about 160kbps. + /// + protected const Int64 m_minimumFlow = m_minimumDripRate * 15; // // The maximum rate for flow control. Drip rate can never be -- cgit v1.1 From a3bd769cb33ee59b883998205454bb340d44cb9e Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 22 Apr 2011 14:55:23 -0700 Subject: Added a second immediate queue to be used for the BestAvatar policy and currently used for all of an avatars attachments by the other policies. Also changed the way items are pulled from the update queues to bias close objects even more. --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 34 +++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 2e80156..a7637c0 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Scenes // If this is an update for our own avatar give it the highest priority if (client.AgentId == entity.UUID) - return PriorityQueue.ImmediateQueue; + return 0; uint priority; @@ -119,16 +119,40 @@ namespace OpenSim.Region.Framework.Scenes private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity) { - return 1; + // And anything attached to this avatar gets top priority as well + if (entity is SceneObjectPart) + { + SceneObjectPart sop = (SceneObjectPart)entity; + if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) + return 1; + } + + return PriorityQueue.NumberOfImmediateQueues; // first queue past the immediate queues } private uint GetPriorityByDistance(IClientAPI client, ISceneEntity entity) { + // And anything attached to this avatar gets top priority as well + if (entity is SceneObjectPart) + { + SceneObjectPart sop = (SceneObjectPart)entity; + if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) + return 1; + } + return ComputeDistancePriority(client,entity,false); } private uint GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) { + // And anything attached to this avatar gets top priority as well + if (entity is SceneObjectPart) + { + SceneObjectPart sop = (SceneObjectPart)entity; + if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) + return 1; + } + return ComputeDistancePriority(client,entity,true); } @@ -197,8 +221,10 @@ namespace OpenSim.Region.Framework.Scenes // And convert the distance to a priority queue, this computation gives queues // at 10, 20, 40, 80, 160, 320, 640, and 1280m - uint pqueue = 1; - for (int i = 0; i < 8; i++) + uint pqueue = PriorityQueue.NumberOfImmediateQueues; + uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues; + + for (int i = 0; i < queues - 1; i++) { if (distance < 10 * Math.Pow(2.0,i)) break; -- cgit v1.1 From 44e43d9d240735695668849fbd7aaafd339f262d Mon Sep 17 00:00:00 2001 From: E. Allen Soard Date: Fri, 15 Apr 2011 06:17:26 -0700 Subject: Added MaxAgents configuration option to RegionConfig.ini allowing region hosters to setup regions maintaining more control over system resources. --- OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index ab90e90..3aed6ba 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -125,7 +125,10 @@ namespace OpenSim.Region.CoreModules.World.Estate else Scene.RegionInfo.RegionSettings.AllowLandResell = true; - Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents; + if((byte)maxAgents <= Scene.RegionInfo.AgentCapacity) + Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents; + else + Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity; Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor; -- cgit v1.1 From 024c12abc3aa42432e55e322141cad1edeb5bad1 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 25 Apr 2011 10:44:41 -0700 Subject: Cleaned up various configuration options. Removed the category throttle limits because the only ones used now are the defaults (which are overwritten by the client throttles anyway). Updated the default rates to correspond to about 350kbps. Also added a configuration to disable adaptive throttle. The default is the previous behavior (no adaptation). --- .../Region/ClientStack/LindenUDP/LLUDPClient.cs | 13 ++-- .../Region/ClientStack/LindenUDP/ThrottleRates.cs | 80 ++++------------------ .../Region/ClientStack/LindenUDP/TokenBucket.cs | 19 +++-- .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 18 ++--- 4 files changed, 43 insertions(+), 87 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 103ec66..494cb0c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs @@ -181,9 +181,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_maxRTO = maxRTO; // Create a token bucket throttle for this client that has the scene token bucket as a parent - m_throttleClient = new AdaptiveTokenBucket(parentThrottle, rates.TotalLimit); + m_throttleClient = new AdaptiveTokenBucket(parentThrottle, rates.Total, rates.AdaptiveThrottlesEnabled); // Create a token bucket throttle for the total categary with the client bucket as a throttle - m_throttleCategory = new TokenBucket(m_throttleClient, rates.TotalLimit); + m_throttleCategory = new TokenBucket(m_throttleClient, rates.Total); // Create an array of token buckets for this clients different throttle categories m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; @@ -194,7 +194,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Initialize the packet outboxes, where packets sit while they are waiting for tokens m_packetOutboxes[i] = new OpenSim.Framework.LocklessQueue(); // Initialize the token buckets that control the throttling for each category - m_throttleCategories[i] = new TokenBucket(m_throttleCategory, rates.GetLimit(type)); + m_throttleCategories[i] = new TokenBucket(m_throttleCategory, rates.GetRate(type)); } // Default the retransmission timeout to three seconds @@ -341,12 +341,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP task = Math.Max(task, LLUDPServer.MTU); texture = Math.Max(texture, LLUDPServer.MTU); asset = Math.Max(asset, LLUDPServer.MTU); - state = Math.Max(state, LLUDPServer.MTU); - int total = resend + land + wind + cloud + task + texture + asset + state; + int total = resend + land + wind + cloud + task + texture + asset; - //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, State={8}, Total={9}", - // AgentID, resend, land, wind, cloud, task, texture, asset, state, total); + //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, Total={8}", + // AgentID, resend, land, wind, cloud, task, texture, asset, total); // Update the token buckets with new throttle values TokenBucket bucket; diff --git a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs index aaf6e26..c9aac0b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs @@ -52,30 +52,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP public int Texture; /// Drip rate for asset packets public int Asset; - /// Drip rate for state packets - public int State; + /// Drip rate for the parent token bucket public int Total; - /// Maximum burst rate for resent packets - public int ResendLimit; - /// Maximum burst rate for land packets - public int LandLimit; - /// Maximum burst rate for wind packets - public int WindLimit; - /// Maximum burst rate for cloud packets - public int CloudLimit; - /// Maximum burst rate for task (state and transaction) packets - public int TaskLimit; - /// Maximum burst rate for texture packets - public int TextureLimit; - /// Maximum burst rate for asset packets - public int AssetLimit; - /// Maximum burst rate for state packets - public int StateLimit; - /// Burst rate for the parent token bucket - public int TotalLimit; - + /// Flag used to enable adaptive throttles + public bool AdaptiveThrottlesEnabled; + /// /// Default constructor /// @@ -86,26 +69,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP { IConfig throttleConfig = config.Configs["ClientStack.LindenUDP"]; - Resend = throttleConfig.GetInt("resend_default", 12500); - Land = throttleConfig.GetInt("land_default", 1000); - Wind = throttleConfig.GetInt("wind_default", 1000); - Cloud = throttleConfig.GetInt("cloud_default", 1000); - Task = throttleConfig.GetInt("task_default", 1000); - Texture = throttleConfig.GetInt("texture_default", 1000); - Asset = throttleConfig.GetInt("asset_default", 1000); - State = throttleConfig.GetInt("state_default", 1000); - - ResendLimit = throttleConfig.GetInt("resend_limit", 18750); - LandLimit = throttleConfig.GetInt("land_limit", 29750); - WindLimit = throttleConfig.GetInt("wind_limit", 18750); - CloudLimit = throttleConfig.GetInt("cloud_limit", 18750); - TaskLimit = throttleConfig.GetInt("task_limit", 18750); - TextureLimit = throttleConfig.GetInt("texture_limit", 55750); - AssetLimit = throttleConfig.GetInt("asset_limit", 27500); - StateLimit = throttleConfig.GetInt("state_limit", 37000); + Resend = throttleConfig.GetInt("resend_default", 6625); + Land = throttleConfig.GetInt("land_default", 9125); + Wind = throttleConfig.GetInt("wind_default", 1750); + Cloud = throttleConfig.GetInt("cloud_default", 1750); + Task = throttleConfig.GetInt("task_default", 18500); + Texture = throttleConfig.GetInt("texture_default", 18500); + Asset = throttleConfig.GetInt("asset_default", 10500); Total = throttleConfig.GetInt("client_throttle_max_bps", 0); - TotalLimit = Total; + + AdaptiveThrottlesEnabled = throttleConfig.GetBoolean("enable_adaptive_throttles", false); } catch (Exception) { } } @@ -128,34 +102,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP return Texture; case ThrottleOutPacketType.Asset: return Asset; - case ThrottleOutPacketType.State: - return State; - case ThrottleOutPacketType.Unknown: - default: - return 0; - } - } - - public int GetLimit(ThrottleOutPacketType type) - { - switch (type) - { - case ThrottleOutPacketType.Resend: - return ResendLimit; - case ThrottleOutPacketType.Land: - return LandLimit; - case ThrottleOutPacketType.Wind: - return WindLimit; - case ThrottleOutPacketType.Cloud: - return CloudLimit; - case ThrottleOutPacketType.Task: - return TaskLimit; - case ThrottleOutPacketType.Texture: - return TextureLimit; - case ThrottleOutPacketType.Asset: - return AssetLimit; - case ThrottleOutPacketType.State: - return StateLimit; case ThrottleOutPacketType.Unknown: default: return 0; diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index 677d3d1..2ec79ab 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -340,6 +340,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP set { m_maxDripRate = (value == 0 ? 0 : Math.Max(value,m_minimumFlow)); } } + private bool m_enabled = false; + // // // @@ -357,9 +359,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP // // // - public AdaptiveTokenBucket(TokenBucket parent, Int64 maxDripRate) : base(parent,m_minimumFlow) + public AdaptiveTokenBucket(TokenBucket parent, Int64 maxDripRate, bool enabled) : base(parent,maxDripRate) { - MaxDripRate = maxDripRate; + m_enabled = enabled; + + if (m_enabled) + { + m_log.WarnFormat("[TOKENBUCKET] Adaptive throttle enabled"); + MaxDripRate = maxDripRate; + AdjustedDripRate = m_minimumFlow; + } } // @@ -368,7 +377,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void ExpirePackets(Int32 count) { // m_log.WarnFormat("[ADAPTIVEBUCKET] drop {0} by {1} expired packets",AdjustedDripRate,count); - AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,count)); + if (m_enabled) + AdjustedDripRate = (Int64) (AdjustedDripRate / Math.Pow(2,count)); } // @@ -376,7 +386,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // public void AcknowledgePackets(Int32 count) { - AdjustedDripRate = AdjustedDripRate + count; + if (m_enabled) + AdjustedDripRate = AdjustedDripRate + count; } } } diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index ddbc079..db17d8f 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -398,7 +398,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden if (client is LLClientView) { LLClientView llClient = client as LLClientView; - + if (firstClient) { report.AppendLine(GetServerThrottlesReport(llClient.UDPServer)); @@ -451,7 +451,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden int maxRegionNameLength = 14; int maxTypeLength = 4; - string name = "SERVER AGENT LIMITS"; + string name = "SERVER AGENT RATES"; report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); report.Append(GetColumnEntry("-", maxRegionNameLength, columnPadding)); @@ -461,13 +461,13 @@ namespace OpenSim.Region.CoreModules.UDP.Linden report.AppendFormat( "{0,7} {1,8} {2,7} {3,7} {4,7} {5,7} {6,9} {7,7}", (throttleRates.Total * 8) / 1000, - (throttleRates.ResendLimit * 8) / 1000, - (throttleRates.LandLimit * 8) / 1000, - (throttleRates.WindLimit * 8) / 1000, - (throttleRates.CloudLimit * 8) / 1000, - (throttleRates.TaskLimit * 8) / 1000, - (throttleRates.TextureLimit * 8) / 1000, - (throttleRates.AssetLimit * 8) / 1000); + (throttleRates.Resend * 8) / 1000, + (throttleRates.Land * 8) / 1000, + (throttleRates.Wind * 8) / 1000, + (throttleRates.Cloud * 8) / 1000, + (throttleRates.Task * 8) / 1000, + (throttleRates.Texture * 8) / 1000, + (throttleRates.Asset * 8) / 1000); return report.ToString(); } -- cgit v1.1 From ef4f1fc4baaa00c6465c875c2ee02323644d0ed1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 25 Apr 2011 11:00:48 -0700 Subject: Made things consistent between LocalInventoryServiceConnector and RemoteXInventoryServiceConnector on GetFolderContent. --- .../Inventory/LocalInventoryServiceConnector.cs | 9 ++++-- .../Inventory/RemoteXInventoryServiceConnector.cs | 34 +++++++++++++++++----- 2 files changed, 32 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index c7244c8..6dd871f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -182,9 +182,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public InventoryCollection GetFolderContent(UUID userID, UUID folderID) { InventoryCollection invCol = m_InventoryService.GetFolderContent(userID, folderID); - if (UserManager != null) - foreach (InventoryItemBase item in invCol.Items) - UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); + Util.FireAndForget(delegate + { + if (UserManager != null) + foreach (InventoryItemBase item in invCol.Items) + UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); + }); return invCol; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index bd01bb9..8f1f257 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs @@ -46,10 +46,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_Enabled = false; - private bool m_Initialized = false; -// private Scene m_Scene; + private Scene m_Scene; private XInventoryServicesConnector m_RemoteConnector; + private IUserManagement m_UserManager; + private IUserManagement UserManager + { + get + { + if (m_UserManager == null) + { + m_UserManager = m_Scene.RequestModuleInterface(); + } + return m_UserManager; + } + } + public Type ReplaceableInterface { get { return null; } @@ -114,12 +126,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (!m_Enabled) return; - if (!m_Initialized) - { - m_Initialized = true; - } - scene.RegisterModuleInterface(this); + + if (m_Scene == null) + m_Scene = scene; } public void RemoveRegion(Scene scene) @@ -173,7 +183,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public InventoryCollection GetFolderContent(UUID userID, UUID folderID) { - return m_RemoteConnector.GetFolderContent(userID, folderID); + InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); + Util.FireAndForget(delegate + { + if (UserManager != null) + foreach (InventoryItemBase item in invCol.Items) + UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); + }); + + return invCol; } public List GetFolderItems(UUID userID, UUID folderID) -- cgit v1.1 From 77ab7ce084d32c45273d79e9ec4f52c43e3a1d97 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 25 Apr 2011 15:11:29 -0700 Subject: Fixed the transmission of throttles from root agent to child agents. Child throttles are based on the number of child agents known to the root and at least 1/4 of the throttle given to the root. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 2 +- .../Region/ClientStack/LindenUDP/LLUDPClient.cs | 40 ++++++++++++++-------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 33 ++++++++---------- 3 files changed, 41 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 32a075a..cdd4224 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -11420,7 +11420,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public byte[] GetThrottlesPacked(float multiplier) { - return m_udpClient.GetThrottlesPacked(); + return m_udpClient.GetThrottlesPacked(multiplier); } /// diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 494cb0c..50f1e2c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs @@ -329,8 +329,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); // State is a subcategory of task that we allocate a percentage to int state = 0; - // int state = (int)((float)task * STATE_TASK_PERCENTAGE); - // task -= state; // Make sure none of the throttles are set below our packet MTU, // otherwise a throttle could become permanently clogged @@ -342,17 +340,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP texture = Math.Max(texture, LLUDPServer.MTU); asset = Math.Max(asset, LLUDPServer.MTU); - int total = resend + land + wind + cloud + task + texture + asset; - + //int total = resend + land + wind + cloud + task + texture + asset; //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, Total={8}", // AgentID, resend, land, wind, cloud, task, texture, asset, total); // Update the token buckets with new throttle values TokenBucket bucket; - bucket = m_throttleCategory; - bucket.RequestedDripRate = total; - bucket = m_throttleCategories[(int)ThrottleOutPacketType.Resend]; bucket.RequestedDripRate = resend; @@ -381,22 +375,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_packedThrottles = null; } - public byte[] GetThrottlesPacked() + public byte[] GetThrottlesPacked(float multiplier) { byte[] data = m_packedThrottles; if (data == null) { + float rate; + data = new byte[7 * 4]; int i = 0; - Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Resend].RequestedDripRate), 0, data, i, 4); i += 4; - Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Land].RequestedDripRate), 0, data, i, 4); i += 4; - Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Wind].RequestedDripRate), 0, data, i, 4); i += 4; - Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].RequestedDripRate), 0, data, i, 4); i += 4; - Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Task].RequestedDripRate), 0, data, i, 4); i += 4; - Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Texture].RequestedDripRate), 0, data, i, 4); i += 4; - Buffer.BlockCopy(Utils.FloatToBytes((float)m_throttleCategories[(int)ThrottleOutPacketType.Asset].RequestedDripRate), 0, data, i, 4); i += 4; + // multiply by 8 to convert bytes back to bits + rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Resend].RequestedDripRate * 8 * multiplier; + Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; + + rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Land].RequestedDripRate * 8 * multiplier; + Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; + + rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Wind].RequestedDripRate * 8 * multiplier; + Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; + + rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].RequestedDripRate * 8 * multiplier; + Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; + + rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Task].RequestedDripRate * 8 * multiplier; + Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; + + rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Texture].RequestedDripRate * 8 * multiplier; + Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; + + rate = (float)m_throttleCategories[(int)ThrottleOutPacketType.Asset].RequestedDripRate * 8 * multiplier; + Buffer.BlockCopy(Utils.FloatToBytes(rate), 0, data, i, 4); i += 4; m_packedThrottles = data; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 00a1487..ef0eb89 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2632,18 +2632,17 @@ namespace OpenSim.Region.Framework.Scenes cadu.GroupAccess = 0; cadu.Position = AbsolutePosition; cadu.regionHandle = m_rootRegionHandle; + + // Throttles float multiplier = 1; - int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); - if (innacurateNeighbors != 0) - { - multiplier = 1f / (float)innacurateNeighbors; - } - if (multiplier <= 0f) - { + int childRegions = m_knownChildRegions.Count; + if (childRegions != 0) + multiplier = 1f / childRegions; + + // Minimum throttle for a child region is 1/4 of the root region throttle + if (multiplier <= 0.25f) multiplier = 0.25f; - } - //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); cadu.Velocity = Velocity; @@ -3039,16 +3038,14 @@ namespace OpenSim.Region.Framework.Scenes // Throttles float multiplier = 1; - int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); - if (innacurateNeighbors != 0) - { - multiplier = 1f / innacurateNeighbors; - } - if (multiplier <= 0f) - { + int childRegions = m_knownChildRegions.Count; + if (childRegions != 0) + multiplier = 1f / childRegions; + + // Minimum throttle for a child region is 1/4 of the root region throttle + if (multiplier <= 0.25f) multiplier = 0.25f; - } - //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); + cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); cAgent.HeadRotation = m_headrotation; -- cgit v1.1 From 13f141a4d521fc15618c2983c989805d9174b969 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 25 Apr 2011 15:36:59 -0700 Subject: Fix the totals shown by show throttle --- OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 50f1e2c..ca5501d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs @@ -183,7 +183,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Create a token bucket throttle for this client that has the scene token bucket as a parent m_throttleClient = new AdaptiveTokenBucket(parentThrottle, rates.Total, rates.AdaptiveThrottlesEnabled); // Create a token bucket throttle for the total categary with the client bucket as a throttle - m_throttleCategory = new TokenBucket(m_throttleClient, rates.Total); + m_throttleCategory = new TokenBucket(m_throttleClient, 0); // Create an array of token buckets for this clients different throttle categories m_throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; -- cgit v1.1 From b9bca893efaeea3dd76dd3cb2082c181e5510b59 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 25 Apr 2011 16:13:16 -0700 Subject: Removed debug message in the token bucket code --- OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs index 2ec79ab..29fd1a4 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs @@ -365,7 +365,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_enabled) { - m_log.WarnFormat("[TOKENBUCKET] Adaptive throttle enabled"); + // m_log.DebugFormat("[TOKENBUCKET] Adaptive throttle enabled"); MaxDripRate = maxDripRate; AdjustedDripRate = m_minimumFlow; } -- cgit v1.1 From 037373b825235235e89112abe81f985efa052c2a Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 25 Apr 2011 17:11:54 -0700 Subject: recover from unhandled exception from bad rotation data while processing entity updates in LLClientView.cs --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 1f7e66d..0f7f666 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4764,7 +4764,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP data.RelativePosition.ToBytes(objectData, 0); data.Velocity.ToBytes(objectData, 12); data.Acceleration.ToBytes(objectData, 24); - data.RotationOffset.ToBytes(objectData, 36); + try + { + data.RotationOffset.ToBytes(objectData, 36); + } + catch (Exception e) + { + m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString()); + OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36); + } data.AngularVelocity.ToBytes(objectData, 48); ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); -- cgit v1.1 From 1505fbb647f72803efd39aa5e38ad39e6811f6fb Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 26 Apr 2011 08:54:05 -0700 Subject: Add back the high prioritization for other avatars in the BestAvatarResponsiveness prioritizer. --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index a7637c0..4595a29 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -165,18 +165,20 @@ namespace OpenSim.Region.Framework.Scenes { if (!presence.IsChildAgent) { + // All avatars other than our own go into pqueue 1 + if (entity is ScenePresence) + return 1; + if (entity is SceneObjectPart) { + // Attachments are high priority, + if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) + return 1; + // Non physical prims are lower priority than physical prims PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; if (physActor == null || !physActor.IsPhysical) pqueue++; - - // Attachments are high priority, - // MIC: shouldn't these already be in the highest priority queue already - // since their root position is same as the avatars? - if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) - pqueue = 1; } } } -- cgit v1.1 From 16f6f55f2d203f9ef40fba85860bb9dbd416bd0f Mon Sep 17 00:00:00 2001 From: dahlia Date: Tue, 26 Apr 2011 16:22:44 -0700 Subject: network traffic reduction - decrease update frequency for moving avatars when velocity is unchanged --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 34 +++++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ef0eb89..e4413a9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2340,12 +2340,14 @@ namespace OpenSim.Region.Framework.Scenes #region Update Client(s) + /// /// Sends a location update to the client connected to this scenePresence /// /// public void SendTerseUpdateToClient(IClientAPI remoteClient) { + // If the client is inactive, it's getting its updates from another // server. if (remoteClient.IsActive) @@ -2358,8 +2360,8 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); remoteClient.SendPrimUpdate( - this, - PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity + this, + PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); @@ -2367,16 +2369,31 @@ namespace OpenSim.Region.Framework.Scenes } } + + // vars to support reduced update frequency when velocity is unchanged + private Vector3 lastVelocitySentToAllClients = Vector3.Zero; + private int lastTerseUpdateToAllClientsTick = Util.EnvironmentTickCount(); + /// /// Send a location/velocity/accelleration update to all agents in scene /// public void SendTerseUpdateToAllClients() { - m_perfMonMS = Util.EnvironmentTickCount(); - - m_scene.ForEachClient(SendTerseUpdateToClient); + int currentTick = Util.EnvironmentTickCount(); - m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + // decrease update frequency when avatar is moving but velocity is not changing + if (m_velocity.Length() < 0.01f + || Vector3.Distance(lastVelocitySentToAllClients, m_velocity) > 0.01f + || currentTick - lastTerseUpdateToAllClientsTick > 1500) + { + m_perfMonMS = currentTick; + lastVelocitySentToAllClients = m_velocity; + lastTerseUpdateToAllClientsTick = currentTick; + + m_scene.ForEachClient(SendTerseUpdateToClient); + + m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); + } } public void SendCoarseLocations(List coarseLocations, List avatarUUIDs) @@ -3268,10 +3285,7 @@ namespace OpenSim.Region.Framework.Scenes m_updateflag = true; - // The magic constant 0.95f seems to make walking feel less jerky, - // probably because it hackishly accounts for the overall latency of - // these Velocity updates -- Diva - Velocity = force * .95F; + Velocity = force; m_forceToApply = null; } -- cgit v1.1 From 50aa93137d052c643a6ed44c32f0b4c5b32da79e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 28 Apr 2011 00:59:21 +0100 Subject: Fix a bug where physical objects rezzed with an initial velocity by script do not receive this velocity. This is a minimal fix for the 0.7.1 release, pending a non copy/paste solution. This hopefully addresses http://opensimulator.org/mantis/view.php?id=5457 The bug was introduced in commit 3ba5eeb --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0f85925..0b2b01a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -2039,6 +2039,12 @@ namespace OpenSim.Region.Framework.Scenes if (rot != null) group.UpdateGroupRotationR((Quaternion)rot); + // TODO: This needs to be refactored with the similar code in + // SceneGraph.AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) + // possibly by allowing this method to take a null rotation. + if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) + group.RootPart.ApplyImpulse((vel * group.GetMass()), false); + // We can only call this after adding the scene object, since the scene object references the scene // to find out if scripts should be activated at all. group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); -- cgit v1.1 From 549dc5aeb9e693f1f575896796d19b03ec3a732f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 28 Apr 2011 08:58:04 -0700 Subject: Eliminated sAgentCircuitData, a data structure that has been obsolete for quite some time. --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 22bad99..43903ce 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -11635,7 +11635,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP info.userEP = m_userEndPoint; info.proxyEP = null; - info.agentcircuit = new sAgentCircuitData(RequestClientInfo()); + info.agentcircuit = RequestClientInfo(); return info; } -- cgit v1.1 From cd7517ccb9d522f5fecd57523285a0b17c147620 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 28 Apr 2011 22:59:12 +0100 Subject: Stop CHANGED_INVENTORY firing twice if a notecard is edited in prim. Addresses http://opensimulator.org/mantis/view.php?id=5444 Fix is to stop the asset transaction calling UpdateInventoryItem() since the caller is doing it anyway, which is more correct. This did not effect scripts. --- .../Agent/AssetTransaction/AgentAssetsTransactions.cs | 9 +++++---- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++++ OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 7 +++++-- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 771038e..9d8082b 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -41,8 +41,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// public class AgentAssetTransactions { -// private static readonly ILog m_log = LogManager.GetLogger( -// MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // Fields private bool m_dumpAssetsToFile; @@ -149,6 +148,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction if (asset != null) { +// m_log.DebugFormat( +// "[AGENT ASSETS TRANSACTIONS]: Updating item {0} in {1} for transaction {2}", +// item.Name, part.Name, transactionID); + asset.FullID = UUID.Random(); asset.Name = item.Name; asset.Description = item.Description; @@ -156,8 +159,6 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction item.AssetID = asset.FullID; m_Scene.AssetService.Store(asset); - - part.Inventory.UpdateInventoryItem(item); } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 0b2b01a..b0f0de6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1430,6 +1430,10 @@ namespace OpenSim.Region.Framework.Scenes } else // Updating existing item with new perms etc { +// m_log.DebugFormat( +// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", +// currentItem.Name, part.Name); + IAgentAssetTransactions agentTransactions = this.RequestModuleInterface(); if (agentTransactions != null) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 3281eab..3b60f8c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -693,8 +693,9 @@ namespace OpenSim.Region.Framework.Scenes { TaskInventoryItem it = GetInventoryItem(item.ItemID); if (it != null) - { +// m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); + item.ParentID = m_part.UUID; item.ParentPartID = m_part.UUID; @@ -711,14 +712,16 @@ namespace OpenSim.Region.Framework.Scenes m_items[item.ItemID] = item; m_inventorySerial++; } - + if (fireScriptEvents) m_part.TriggerScriptChangedEvent(Changed.INVENTORY); + if (considerChanged) { HasInventoryChanged = true; m_part.ParentGroup.HasGroupChanged = true; } + return true; } else -- cgit v1.1 From 9892e115ccdcc8567087041917fb5c7694aa8836 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 28 Apr 2011 20:19:54 -0700 Subject: Fatpack message on agent transfers: 1 message only (UpdateAgent) containing the agent and all attachments. Preserves backwards compatibility -- older sims get passed attachments one by one. Meaning that I finally introduced versioning in the simulation service. --- .../Avatar/Attachments/AttachmentsModule.cs | 13 +-- .../EntityTransfer/EntityTransferModule.cs | 61 +++++----- .../EntityTransfer/HGEntityTransferModule.cs | 5 +- .../Simulation/LocalSimulationConnector.cs | 6 +- .../Simulation/RemoteSimulationConnector.cs | 7 +- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 + OpenSim/Region/Framework/Scenes/ScenePresence.cs | 124 +++++---------------- 8 files changed, 84 insertions(+), 138 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index ff26264..520d794 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -562,14 +562,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// /// - /// + /// /// - protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 AttachOffset, bool silent) + protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) { - // don't attach attachments to child agents - if (avatar.IsChildAgent) return; -// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name); + m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, + attachmentpoint, attachOffset, so.RootPart.AttachedPos); so.DetachFromBackup(); @@ -590,8 +589,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.RootPart.PhysActor = null; } - so.AbsolutePosition = AttachOffset; - so.RootPart.AttachedPos = AttachOffset; + so.AbsolutePosition = attachOffset; + so.RootPart.AttachedPos = attachOffset; so.RootPart.IsAttachment = true; so.RootPart.SetParentLocalId(avatar.LocalId); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index c88be7d..1054785 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -285,11 +285,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } string reason; - if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out reason)) + string version; + if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason)) { sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason); return; } + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Destination is running version {0}", version); sp.ControllingClient.SendTeleportStart(teleportFlags); @@ -371,20 +373,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); } - // Expect avatar crossing is a heavy-duty function at the destination. - // That is where MakeRoot is called, which fetches appearance and inventory. - // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. - //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, - // position, false); - - //{ - // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); - // // We should close that agent we just created over at destination... - // List lst = new List(); - // lst.Add(reg.RegionHandle); - // SendCloseChildAgentAsync(avatar.UUID, lst); - // return; - //} SetInTransit(sp.UUID); @@ -426,7 +414,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation - // that the client contacted the destination before we send the attachments and close things here. + // that the client contacted the destination before we close things here. if (!WaitForCallback(sp.UUID)) { m_log.WarnFormat( @@ -437,14 +425,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - CrossAttachmentsIntoNewRegion(finalDestination, sp, true); + // For backwards compatibility + if (version == "Unknown" || version == string.Empty) + { + // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Old simulator, sending attachments one by one..."); + CrossAttachmentsIntoNewRegion(finalDestination, sp, true); + } + + // May need to logout or other cleanup + AgentHasMovedAway(sp, logout); // Well, this is it. The agent is over there. KillEntity(sp.Scene, sp.LocalId); - // May need to logout or other cleanup - AgentHasMovedAway(sp.ControllingClient.SessionId, logout); // Now let's make it officially a child agent sp.MakeChildAgent(); @@ -513,8 +507,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } - protected virtual void AgentHasMovedAway(UUID sessionID, bool logout) + protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) { + foreach (SceneObjectGroup sop in sp.Attachments) + { + sop.Scene.DeleteSceneObject(sop, true); + } + sp.Attachments.Clear(); } protected void KillEntity(Scene scene, uint localID) @@ -784,7 +783,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); string reason; - if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out reason)) + string version; + if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out version, out reason)) { agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); if (r == null) @@ -804,7 +804,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.InTransit(); CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; - d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, CrossAgentToNewRegionCompleted, d); + d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d); return true; } @@ -861,17 +861,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer icon.EndInvoke(iar); } - public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying); + public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying, string version); /// /// This Closes child agents on neighbouring regions /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// - protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying) + protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying, string version) { ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", agent.Firstname, agent.Lastname, neighbourx, neighboury, version); Scene m_scene = agent.Scene; @@ -945,7 +945,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.SendOtherAgentsAvatarDataToMe(); agent.SendOtherAgentsAppearanceToMe(); - CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); + // Backwards compatibility + if (version == "Unknown" || version == string.Empty) + { + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Old neighbor, passing attachments one by one..."); + CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); + } + + AgentHasMovedAway(agent, false); // the user may change their profile information in other region, // so the userinfo in UserProfileCache is not reliable any more, delete it diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 79e76b4..5c53f78 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -142,11 +142,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return false; } - protected override void AgentHasMovedAway(UUID sessionID, bool logout) + protected override void AgentHasMovedAway(ScenePresence sp, bool logout) { + base.AgentHasMovedAway(sp, logout); if (logout) // Log them out of this grid - m_aScene.PresenceService.LogoutAgent(sessionID); + m_aScene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); } protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index a298b65..2cf02b5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -41,6 +41,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // Version of this service + private const string m_Version = "SIMULATION/0.1"; + private List m_sceneList = new List(); private IEntityTransferModule m_AgentTransferModule; @@ -257,9 +260,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason) + public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) { reason = "Communications failure"; + version = m_Version; if (destination == null) return false; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 67f4d60..7858f2a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -229,19 +229,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation } - public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason) + public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) { reason = "Communications failure"; + version = "Unknown"; if (destination == null) return false; // Try local first - if (m_localBackend.QueryAccess(destination, id, position, out reason)) + if (m_localBackend.QueryAccess(destination, id, position, out version, out reason)) return true; // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.QueryAccess(destination, id, position, out reason); + return m_remoteConnector.QueryAccess(destination, id, position, out version, out reason); return false; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 01de824..696c6ee 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2316,7 +2316,9 @@ namespace OpenSim.Region.Framework.Scenes /// public bool IncomingCreateObject(ISceneObject sog) { - //m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); + //m_log.DebugFormat(" >>> IncomingCreateObject(sog) <<< {0} deleted? {1} isAttach? {2}", ((SceneObjectGroup)sog).AbsolutePosition, + // ((SceneObjectGroup)sog).IsDeleted, ((SceneObjectGroup)sog).RootPart.IsAttachment); + SceneObjectGroup newObject; try { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 19a9506..bccbe68 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3361,6 +3361,8 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup sog = Copy(false); sog.m_isDeleted = false; + sog.RootPart.IsAttachment = false; + sog.RootPart.GroupPosition = sog.RootPart.AttachedPos; return sog; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e4413a9..507fc50 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3078,54 +3078,6 @@ namespace OpenSim.Region.Framework.Scenes cAgent.Appearance = new AvatarAppearance(m_appearance); -/* - try - { - // We might not pass the Wearables in all cases... - // They're only needed so that persistent changes to the appearance - // are preserved in the new region where the user is moving to. - // But in Hypergrid we might not let this happen. - int i = 0; - UUID[] wears = new UUID[m_appearance.Wearables.Length * 2]; - foreach (AvatarWearable aw in m_appearance.Wearables) - { - if (aw != null) - { - wears[i++] = aw.ItemID; - wears[i++] = aw.AssetID; - } - else - { - wears[i++] = UUID.Zero; - wears[i++] = UUID.Zero; - } - } - cAgent.Wearables = wears; - - cAgent.VisualParams = m_appearance.VisualParams; - - if (m_appearance.Texture != null) - cAgent.AgentTextures = m_appearance.Texture.GetBytes(); - } - catch (Exception e) - { - m_log.Warn("[SCENE PRESENCE]: exception in CopyTo " + e.Message); - } - - //Attachments - List attPoints = m_appearance.GetAttachedPoints(); - if (attPoints != null) - { - //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); - int i = 0; - AvatarAttachment[] attachs = new AvatarAttachment[attPoints.Count]; - foreach (int point in attPoints) - { - attachs[i++] = new AvatarAttachment(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); - } - cAgent.Attachments = attachs; - } -*/ lock (scriptedcontrols) { ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; @@ -3145,9 +3097,21 @@ namespace OpenSim.Region.Framework.Scenes } catch { } - // cAgent.GroupID = ?? - // Groups??? - + // Attachment objects + if (m_attachments != null && m_attachments.Count > 0) + { + cAgent.AttachmentObjects = new List(); + cAgent.AttachmentObjectStates = new List(); + IScriptModule se = m_scene.RequestModuleInterface(); + foreach (SceneObjectGroup sog in m_attachments) + { + // We need to make a copy and pass that copy + // because of transfers withn the same sim + ISceneObject clone = sog.CloneForNewScene(); + cAgent.AttachmentObjects.Add(clone); + cAgent.AttachmentObjectStates.Add(sog.GetStateSnapshot()); + } + } } public void CopyFrom(AgentData cAgent) @@ -3188,50 +3152,6 @@ namespace OpenSim.Region.Framework.Scenes AddToPhysicalScene(isFlying); } -/* - uint i = 0; - try - { - if (cAgent.Wearables == null) - cAgent.Wearables = new UUID[0]; - AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; - for (uint n = 0; n < cAgent.Wearables.Length; n += 2) - { - UUID itemId = cAgent.Wearables[n]; - UUID assetId = cAgent.Wearables[n + 1]; - wears[i++] = new AvatarWearable(itemId, assetId); - } - // m_appearance.Wearables = wears; - Primitive.TextureEntry textures = null; - if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) - textures = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); - - byte[] visuals = null; - - if ((cAgent.VisualParams != null) && (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) - visuals = (byte[])cAgent.VisualParams.Clone(); - - m_appearance = new AvatarAppearance(cAgent.AgentID,wears,textures,visuals); - } - catch (Exception e) - { - m_log.Warn("[SCENE PRESENCE]: exception in CopyFrom " + e.Message); - } - - // Attachments - try - { - if (cAgent.Attachments != null) - { - m_appearance.ClearAttachments(); - foreach (AvatarAttachment att in cAgent.Attachments) - { - m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); - } - } - } - catch { } -*/ try { lock (scriptedcontrols) @@ -3261,8 +3181,18 @@ namespace OpenSim.Region.Framework.Scenes } catch { } - //cAgent.GroupID = ?? - //Groups??? + if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) + { + m_attachments = new List(); + int i = 0; + foreach (ISceneObject so in cAgent.AttachmentObjects) + { + ((SceneObjectGroup)so).LocalId = 0; + ((SceneObjectGroup)so).RootPart.UpdateFlag = 0; + so.SetState(cAgent.AttachmentObjectStates[i++], m_scene); + m_scene.IncomingCreateObject(so); + } + } } public bool CopyAgent(out IAgentData agent) -- cgit v1.1 From 73caa4e94abc920269c2eba8423be49192ef184b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 29 Apr 2011 08:42:51 -0700 Subject: Minor correction to yesterday's changes. Make normal prim crossing (no attach) work well again. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 -- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bccbe68..19a9506 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3361,8 +3361,6 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup sog = Copy(false); sog.m_isDeleted = false; - sog.RootPart.IsAttachment = false; - sog.RootPart.GroupPosition = sog.RootPart.AttachedPos; return sog; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 507fc50..fe4a7d1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3108,6 +3108,9 @@ namespace OpenSim.Region.Framework.Scenes // We need to make a copy and pass that copy // because of transfers withn the same sim ISceneObject clone = sog.CloneForNewScene(); + // Attachment module assumes that GroupPosition holds the offsets...! + ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; + ((SceneObjectGroup)clone).RootPart.IsAttachment = false; cAgent.AttachmentObjects.Add(clone); cAgent.AttachmentObjectStates.Add(sog.GetStateSnapshot()); } -- cgit v1.1