public bool EnqueueOutgoing(OutgoingPacket packet) { int category = (int)packet.Category; if (category >= 0 && category < m_packetOutboxes.Length) { OpenSim.Framework.LocklessQueue <OutgoingPacket> queue = m_packetOutboxes[category]; TokenBucket bucket = m_throttleCategories[category]; if (bucket.RemoveTokens(packet.Buffer.DataLength)) { // Enough tokens were removed from the bucket, the packet will not be queued return(false); } else { // Not enough tokens in the bucket, queue this packet queue.Enqueue(packet); return(true); } } else { // We don't have a token bucket for this category, so it will not be queued return(false); } }
public void QueueRequest(ODERayRequest req) { if (req.Count == 0) { req.Count = DefaultMaxCount; } m_PendingRequests.Enqueue(req); }
public void Enqueue(T item, bool highPriority) { if (highPriority) { highQueue.Enqueue(item); } else { Enqueue(item); } }
/// <summary> /// Queue an outgoing packet if appropriate. /// </summary> /// <param name="packet"></param> /// <param name="forceQueue">Always queue the packet if at all possible.</param> /// <returns> /// true if the packet has been queued, /// false if the packet has not been queued and should be sent immediately. /// </returns> public bool EnqueueOutgoing(OutgoingPacket packet, bool forceQueue) { int category = (int)packet.Category; if (category >= 0 && category < m_packetOutboxes.Length) { OpenSim.Framework.LocklessQueue <OutgoingPacket> queue = m_packetOutboxes[category]; TokenBucket bucket = m_throttleCategories[category]; // Don't send this packet if there is already a packet waiting in the queue // even if we have the tokens to send it, tokens should go to the already // queued packets if (queue.Count > 0) { queue.Enqueue(packet); return(true); } if (!forceQueue && bucket.RemoveTokens(packet.Buffer.DataLength)) { // Enough tokens were removed from the bucket, the packet will not be queued return(false); } else { // Force queue specified or not enough tokens in the bucket, queue this packet queue.Enqueue(packet); return(true); } } else { // We don't have a token bucket for this category, so it will not be queued return(false); } }
public bool EnqueueOutgoing(OutgoingPacket packet) { int category = (int)packet.Category; if (category >= 0 && category < m_packetOutboxes.Length) { OpenSim.Framework.LocklessQueue <OutgoingPacket> queue = m_packetOutboxes[category]; // Not enough tokens in the bucket, queue this packet //check the queue //Dont drop resends this can mess up the buffer pool as well as make the connection situation much worse if (_currentOutboundQueueSize > MAX_TOTAL_QUEUE_SIZE && (packet.Buffer[0] & Helpers.MSG_RESENT) == 0) { //queue already has too much data in it.. //can we drop this packet? byte flags = packet.Buffer[0]; bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; if (!isReliable && packet.Type != PacketType.PacketAck && packet.Type != PacketType.CompletePingCheck) { //packet is unreliable and will be dropped this.TestReportPacketDrop(packet); packet.DecRef(m_udpServer.ByteBufferPool); } else { if (_currentOutboundQueueSize < MAX_TOTAL_QUEUE_SIZE * 1.5) { this.TestReportPacketShouldDrop(packet); Interlocked.Add(ref _currentOutboundQueueSize, packet.DataSize); packet.AddRef(); queue.Enqueue(packet); } else { //this connection is in a pretty critical state and probably will never catch up. //drop all packets until we start to catch up. This includes acks which will disconnect //the client eventually anyways this.TestReportCriticalPacketDrop(packet); packet.DecRef(m_udpServer.ByteBufferPool); } } } else { Interlocked.Add(ref _currentOutboundQueueSize, packet.DataSize); packet.AddRef(); queue.Enqueue(packet); } return(true); } else { // We don't have a token bucket for this category, so it will not be queued return(false); } }