Merge branch 'casper'

avinationmerge
CasperW 2009-12-20 16:20:48 +01:00
commit c7a457f9ee
3 changed files with 6 additions and 132 deletions

View File

@ -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,27 +568,8 @@ 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)

View File

@ -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
/// <summary>Local IP address to bind to in server mode</summary>
protected IPAddress m_localBindAddress;
/// <summary>
/// Standard queue for our outgoing SyncBeginPrioritySend
/// </summary>
private List<UDPPacketBuffer> m_standardQueue = new List<UDPPacketBuffer>();
/// <summary>
/// Medium priority queue for our outgoing SyncBeginPrioritySend
/// </summary>
private List<UDPPacketBuffer> m_mediumPriorityQueue = new List<UDPPacketBuffer>();
/// <summary>
/// Prioritised queue for our outgoing SyncBeginPrioritySend
/// </summary>
private List<UDPPacketBuffer> m_priorityQueue = new List<UDPPacketBuffer>();
/// <summary>UDP socket, used in either client or server mode</summary>
private Socket m_udpSocket;
/// <summary>Flag to process packets asynchronously or synchronously</summary>
private bool m_asyncPacketHandling;
/// <summary>Are we currently sending data asynchronously?</summary>
private volatile bool m_sendingData = false;
/// <summary>The all important shutdown flag</summary>
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) { }

View File

@ -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;
/// <summary>Category this packet belongs to</summary>
public ThrottleOutPacketType Category;
/// <summary>The type of packet so its delivery method can be determined</summary>
public PacketType Type;
/// <summary>
/// Default constructor
/// </summary>