OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
/// <summary>
/// Loops through all of the packet queues for this client and tries to send
/// an outgoing packet from each, obeying the throttling bucket limits
/// </summary>
/// 
/// <remarks>
/// Packet queues are inspected in ascending numerical order starting from 0.  Therefore, queues with a lower 
/// ThrottleOutPacketType number will see their packet get sent first (e.g. if both Land and Wind queues have
/// packets, then the packet at the front of the Land queue will be sent before the packet at the front of the
/// wind queue).
/// 
/// This function is only called from a synchronous loop in the
/// UDPServer so we don't need to bother making this thread safe
/// </remarks>
/// 
/// <returns>True if any packets were sent, otherwise false</returns>
Loops through all of the packet queues for this client and tries to send
an outgoing packet from each, obeying the throttling bucket limits
Loops through all of the packet queues for this client and tries to send an outgoing packet from each obeying the throttling bucket limits
public bool DequeueOutgoing()
        {
            OutgoingPacket packet;
            OpenSim.Framework.LocklessQueue<OutgoingPacket> queue;
            TokenBucket bucket;
            bool packetSent = false;
            ThrottleOutPacketTypeFlags emptyCategories = 0;
            for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++)
            {
                bucket = m_throttleCategories[i];
                if (m_nextPackets[i] != null)
                {
                    OutgoingPacket nextPacket = m_nextPackets[i];
                    if (bucket.RemoveTokens(nextPacket.Buffer.DataLength))
                    {
                        m_udpServer.SendPacketFinal(nextPacket);
                        m_nextPackets[i] = null;
                        packetSent = true;
                    }
                }
                else
                {
                    queue = m_packetOutboxes[i];
                    if (queue.Dequeue(out packet))
                    {
                        if (bucket.RemoveTokens(packet.Buffer.DataLength))
                        {
                            m_udpServer.SendPacketFinal(packet);
                            packetSent = true;
                        }
                        else
                        {
                            m_nextPackets[i] = packet;
                        }
                        if (queue.Count == 0)
                            emptyCategories |= CategoryToFlag(i);
                    }
                    else
                    {
                        emptyCategories |= CategoryToFlag(i);
                    }
                }
            }
            if (emptyCategories != 0)
                BeginFireQueueEmpty(emptyCategories);
            return packetSent;
        }
public bool DequeueOutgoing ( ) { OutgoingPacket packet ; OpenSim . Framework . LocklessQueue < OutgoingPacket > queue ; TokenBucket bucket ; bool packetSent = false ; ThrottleOutPacketTypeFlags emptyCategories = 0 ; for ( int i = 0 ; i < THROTTLE_CATEGORY_COUNT ; i ++ ) { bucket = m_throttleCategories [ i ] ; if ( m_nextPackets [ i ] != null ) { OutgoingPacket nextPacket = m_nextPackets [ i ] ; if ( bucket . RemoveTokens ( nextPacket . Buffer . DataLength ) ) { m_udpServer . SendPacketFinal ( nextPacket ) ; m_nextPackets [ i ] = null ; packetSent = true ; } } else { queue = m_packetOutboxes [ i ] ; if ( queue . Dequeue ( out packet ) ) { if ( bucket . RemoveTokens ( packet . Buffer . DataLength ) ) { m_udpServer . SendPacketFinal ( packet ) ; packetSent = true ; } else { m_nextPackets [ i ] = packet ; } if ( queue . Count == 0 ) emptyCategories |= CategoryToFlag ( i ) ; } else { emptyCategories |= CategoryToFlag ( i ) ; } } } if ( emptyCategories != 0 ) BeginFireQueueEmpty ( emptyCategories ) ; return packetSent ; }
Loops through all of the packet queues for this client and tries to send
an outgoing packet from each, obeying the throttling bucket limits
Loops through all of the packet queues for this client and tries to send an outgoing packet from each obeying the throttling bucket limits
//string queueDebugOutput = String.Empty; // Serious debug business //queueDebugOutput += m_packetOutboxes[i].Count + " ";  // Serious debug business // This bucket was empty the last time we tried to send a packet, // leaving a dequeued packet still waiting to be sent out. Try to // send it again // Send the packet // No dequeued packet waiting to be sent, try to pull one off // this queue // A packet was pulled off the queue. See if we have // enough tokens in the bucket to send it out // Send the packet // Save the dequeued packet for the next iteration // If the queue is empty after this dequeue, fire the queue // empty callback now so it has a chance to fill before we  // get back here // No packets in this queue. Fire the queue empty callback // if it has not been called recently //m_log.Info("[LLUDPCLIENT]: Queues: " + queueDebugOutput); // Serious debug business
True if any packets were sent, otherwise false
True if any packets were sent otherwise false
remarks
Packet queues are inspected in ascending numerical order starting from 0.  Therefore, queues with a lower
ThrottleOutPacketType number will see their packet get sent first .

This function is only called from a synchronous loop in the
UDPServer so we don't need to bother making this thread safe
Packet queues are inspected in ascending numerical order starting from 0 . Therefore queues with a lower ThrottleOutPacketType number will see their packet get sent first . This function is only called from a synchronous loop in the UDPServer so we don ' t need to bother making this thread safe