From 31bf25d05e09395416c0427e783f8685a9e69889 Mon Sep 17 00:00:00 2001 From: CasperW Date: Sun, 20 Dec 2009 16:18:43 +0100 Subject: Reverted my changes to jhurliman's packet stack since it currently causes more problems than it resolves. The stack DOES need a rework particularly with regards to priorities, but this is not it. --- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 27 +----- .../Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 107 +-------------------- .../Region/ClientStack/LindenUDP/OutgoingPacket.cs | 4 +- 3 files changed, 6 insertions(+), 132 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 4d9f58f..3c4fa72 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -402,7 +402,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Queue or Send OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); - outgoingPacket.Type = type; if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) SendPacketFinal(outgoingPacket); @@ -514,7 +513,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP byte flags = buffer.Data[0]; bool isResend = (flags & Helpers.MSG_RESENT) != 0; bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; - bool sendSynchronous = false; LLUDPClient udpClient = outgoingPacket.Client; if (!udpClient.IsConnected) @@ -570,28 +568,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (isReliable) Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength); - //Some packet types need to be sent synchonously. - //Sorry, i know it's not optimal, but until the LL client - //manages packets correctly and re-orders them as required, this is necessary. - - // Put the UDP payload on the wire - if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate) - { - SyncBeginPrioritySend(buffer, 2); // highest priority - } - else if (outgoingPacket.Type == PacketType.ObjectUpdate - || outgoingPacket.Type == PacketType.LayerData) - { - SyncBeginPrioritySend(buffer, 1); // medium priority - } - else - { - SyncBeginPrioritySend(buffer, 0); // normal priority - } - - //AsyncBeginSend(buffer); - + AsyncBeginSend(buffer); + // Keep track of when this packet was sent out (right now) outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue; } @@ -872,7 +851,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Buffer.BlockCopy(packetData, 0, buffer.Data, 0, length); - SyncBeginPrioritySend(buffer, 1); //Setting this to a medium priority should help minimise resends + AsyncBeginSend(buffer); } private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo) diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs index de2cd24..d2779ba 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs @@ -29,7 +29,6 @@ using System; using System.Net; using System.Net.Sockets; using System.Threading; -using System.Collections.Generic; using log4net; namespace OpenMetaverse @@ -53,30 +52,12 @@ namespace OpenMetaverse /// Local IP address to bind to in server mode protected IPAddress m_localBindAddress; - /// - /// Standard queue for our outgoing SyncBeginPrioritySend - /// - private List m_standardQueue = new List(); - - /// - /// Medium priority queue for our outgoing SyncBeginPrioritySend - /// - private List m_mediumPriorityQueue = new List(); - - /// - /// Prioritised queue for our outgoing SyncBeginPrioritySend - /// - private List m_priorityQueue = new List(); - /// UDP socket, used in either client or server mode private Socket m_udpSocket; /// Flag to process packets asynchronously or synchronously private bool m_asyncPacketHandling; - /// Are we currently sending data asynchronously? - private volatile bool m_sendingData = false; - /// The all important shutdown flag private volatile bool m_shutdownFlag = true; @@ -265,51 +246,7 @@ namespace OpenMetaverse } } - public void SyncBeginPrioritySend(UDPPacketBuffer buf, int Priority) - { - if (!m_shutdownFlag) - { - if (!m_sendingData) - { - m_sendingData = true; - try - { - AsyncBeginSend(buf); - } - catch (SocketException) { } - catch (ObjectDisposedException) { } - } - else - { - if (Priority == 2) - { - lock (m_priorityQueue) - { - m_priorityQueue.Add(buf); - } - } - else - { - if (Priority != 0) - { - lock (m_mediumPriorityQueue) - { - m_mediumPriorityQueue.Add(buf); - } - } - else - { - lock (m_standardQueue) - { - m_standardQueue.Add(buf); - } - } - } - } - } - } - - private void AsyncBeginSend(UDPPacketBuffer buf) + public void AsyncBeginSend(UDPPacketBuffer buf) { if (!m_shutdownFlag) { @@ -333,48 +270,8 @@ namespace OpenMetaverse { try { +// UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState; m_udpSocket.EndSendTo(result); - - if (m_sendingData) - { - lock (m_priorityQueue) - { - if (m_priorityQueue.Count > 0) - { - UDPPacketBuffer buf = m_priorityQueue[0]; - m_priorityQueue.RemoveAt(0); - AsyncBeginSend(buf); - } - else - { - lock (m_mediumPriorityQueue) - { - if (m_mediumPriorityQueue.Count > 0) - { - UDPPacketBuffer buf = m_mediumPriorityQueue[0]; - m_mediumPriorityQueue.RemoveAt(0); - AsyncBeginSend(buf); - } - else - { - lock (m_standardQueue) - { - if (m_standardQueue.Count > 0) - { - UDPPacketBuffer buf = m_standardQueue[0]; - m_standardQueue.RemoveAt(0); - AsyncBeginSend(buf); - } - else - { - m_sendingData = false; - } - } - } - } - } - } - } } catch (SocketException) { } catch (ObjectDisposedException) { } diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs index 7dc42d3..1a1a1cb 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs @@ -28,7 +28,6 @@ using System; using OpenSim.Framework; using OpenMetaverse; -using OpenMetaverse.Packets; namespace OpenSim.Region.ClientStack.LindenUDP { @@ -53,8 +52,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public int TickCount; /// Category this packet belongs to public ThrottleOutPacketType Category; - /// The type of packet so its delivery method can be determined - public PacketType Type; + /// /// Default constructor /// -- cgit v1.1