minor refactor so that I can now grok what happens for outgoing packets
parent
c1fdba8a6f
commit
2adcdd3d15
|
@ -2240,14 +2240,11 @@ namespace OpenSim.Region.ClientStack
|
|||
set { m_circuitCode = value; }
|
||||
}
|
||||
|
||||
protected virtual void ProcessOutPacket(Packet Pack)
|
||||
{
|
||||
// Keep track of when this packet was sent out
|
||||
Pack.TickCount = System.Environment.TickCount;
|
||||
|
||||
if (!Pack.Header.Resent)
|
||||
// A thread safe sequence number allocator.
|
||||
protected uint NextSeqNum()
|
||||
{
|
||||
// Set the sequence number
|
||||
uint seq = 1;
|
||||
lock (SequenceLock)
|
||||
{
|
||||
if (Sequence >= MAX_SEQUENCE)
|
||||
|
@ -2258,11 +2255,12 @@ namespace OpenSim.Region.ClientStack
|
|||
{
|
||||
Sequence++;
|
||||
}
|
||||
|
||||
Pack.Header.Sequence = Sequence;
|
||||
seq = Sequence;
|
||||
}
|
||||
return seq;
|
||||
}
|
||||
|
||||
if (Pack.Header.Reliable) //DIRTY HACK
|
||||
protected void AddAck(Packet Pack)
|
||||
{
|
||||
lock (NeedAck)
|
||||
{
|
||||
|
@ -2288,17 +2286,15 @@ namespace OpenSim.Region.ClientStack
|
|||
// packet.Type.ToString(), Helpers.LogLevel.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't append ACKs to resent packets, in case that's what was causing the
|
||||
// delivery to fail
|
||||
if (!Pack.Header.Resent)
|
||||
protected virtual void SetPendingAcks(ref Packet Pack)
|
||||
{
|
||||
// Append any ACKs that need to be sent out to this packet
|
||||
lock (PendingAcks)
|
||||
{
|
||||
if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS &&
|
||||
Pack.Type != PacketType.PacketAck &&
|
||||
Pack.Type != PacketType.LogoutRequest)
|
||||
// TODO: If we are over MAX_APPENDED_ACKS we should drain off some of these
|
||||
if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS)
|
||||
{
|
||||
Pack.Header.AckList = new uint[PendingAcks.Count];
|
||||
int i = 0;
|
||||
|
@ -2314,24 +2310,40 @@ namespace OpenSim.Region.ClientStack
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ProcessOutPacket(Packet Pack)
|
||||
{
|
||||
// Keep track of when this packet was sent out
|
||||
Pack.TickCount = System.Environment.TickCount;
|
||||
|
||||
if (!Pack.Header.Resent)
|
||||
{
|
||||
Pack.Header.Sequence = NextSeqNum();
|
||||
|
||||
if (Pack.Header.Reliable) //DIRTY HACK
|
||||
{
|
||||
AddAck(Pack); // this adds the need to ack this packet later
|
||||
|
||||
if (Pack.Type != PacketType.PacketAck && Pack.Type != PacketType.LogoutRequest)
|
||||
{
|
||||
SetPendingAcks(ref Pack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte[] ZeroOutBuffer = new byte[4096];
|
||||
byte[] sendbuffer;
|
||||
sendbuffer = Pack.ToBytes();
|
||||
|
||||
// Actually make the byte array and send it
|
||||
try
|
||||
{
|
||||
byte[] sendbuffer = Pack.ToBytes();
|
||||
if (Pack.Header.Zerocoded)
|
||||
{
|
||||
byte[] ZeroOutBuffer = new byte[4096];
|
||||
int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
|
||||
m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); //userEP);
|
||||
m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode);
|
||||
//userEP);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
Loading…
Reference in New Issue