changes on lludp acks and resends

This commit is contained in:
UbitUmarov
2019-12-18 23:26:13 +00:00
parent 7516288634
commit 066a6fbaa1
5 changed files with 196 additions and 181 deletions

View File

@@ -880,8 +880,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// 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
// packet so that it isn't sent before a queued update packet.
bool requestQueue = type == PacketType.KillObject;
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, requestQueue, highPriority))
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, highPriority))
{
SendPacketFinal(outgoingPacket);
return true;
@@ -952,7 +951,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
public void SendUDPPacket(
LLUDPClient udpClient, UDPPacketBuffer buffer, ThrottleOutPacketType category, UnackedPacketMethod method, bool forcequeue, bool zerocode)
LLUDPClient udpClient, UDPPacketBuffer buffer, ThrottleOutPacketType category, UnackedPacketMethod method, bool zerocode)
{
bool highPriority = false;
@@ -971,7 +970,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if ((outgoingPacket.Buffer.Data[0] & Helpers.MSG_RELIABLE) != 0)
outgoingPacket.UnackedMethod = ((method == null) ? delegate (OutgoingPacket oPacket) { ResendUnacked(oPacket); } : method);
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, forcequeue, highPriority))
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, highPriority))
SendPacketFinal(outgoingPacket);
}
@@ -991,7 +990,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if ((outgoingPacket.Buffer.Data[0] & Helpers.MSG_RELIABLE) != 0)
outgoingPacket.UnackedMethod = delegate (OutgoingPacket oPacket) { ResendUnacked(oPacket); };
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, false, highPriority))
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, highPriority))
SendPacketFinal(outgoingPacket);
}
@@ -1056,11 +1055,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
data[7] = udpClient.CurrentPingSequence++;
// older seq number of our un ack packets, so viewers could clean deduplication lists TODO
//Utils.UIntToBytes(0, data, 8);
data[8] = 0;
data[9] = 0;
data[10] = 0;
data[11] = 0;
Utils.UIntToBytes(udpClient.NeedAcks.Oldest(), data, 8);
buf.DataLength = 12;
SendUDPPacket(udpClient, buf, ThrottleOutPacketType.Unknown);
@@ -1140,7 +1135,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// 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);
@@ -1162,7 +1156,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return;
LLUDPClient udpClient = outgoingPacket.Client;
if (!udpClient.IsConnected)
{
FreeUDPBuffer(buffer);
return;
}
byte flags = buffer.Data[0];
bool isResend = (flags & Helpers.MSG_RESENT) != 0;
@@ -1172,7 +1169,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int dataLength = buffer.DataLength;
// only append acks on plain reliable messages
if (flags == Helpers.MSG_RELIABLE)
if (flags == Helpers.MSG_RELIABLE && outgoingPacket.UnackedMethod == null)
{
// Keep appending ACKs until there is no room left in the buffer or there are
// no more ACKs to append
@@ -1211,10 +1208,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Stats tracking
Interlocked.Increment(ref udpClient.PacketsSent);
PacketsSentCount++;
SyncSend(buffer);
// Keep track of when this packet was sent out (right now)
outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
int enow = Environment.TickCount & Int32.MaxValue;
Interlocked.Exchange(ref outgoingPacket.TickCount, enow);
if (outgoingPacket.UnackedMethod == null)
FreeUDPBuffer(buffer);
@@ -1935,7 +1934,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
m_resendUnacked = true;
m_elapsedMSOutgoingPacketHandler = 0.0;
m_elapsed100MSOutgoingPacketHandler += 1;
++m_elapsed100MSOutgoingPacketHandler;
}
// Check for pending outgoing ACKs every 500ms
@@ -1943,7 +1942,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
m_sendAcks = true;
m_elapsed100MSOutgoingPacketHandler = 0;
m_elapsed500MSOutgoingPacketHandler += 1;
++m_elapsed500MSOutgoingPacketHandler;
}
// Send pings to clients every 5000ms