Ejemplo n.º 1
0
        private void ThrottleCheck(ref LLPacketThrottle throttle, ref Queue<LLQueItem> q, LLQueItem item)
        {
            // The idea..  is if the packet throttle queues are empty
            // and the client is under throttle for the type.  Queue
            // it up directly.  This basically short cuts having to
            // wait for the timer to fire to put things into the
            // output queue

            if ((q.Count == 0) && (throttle.UnderLimit()))
            {
                try
                {
                    Monitor.Enter(this);
                    throttle.AddBytes(item.Length);
                    TotalThrottle.AddBytes(item.Length);
                    SendQueue.Enqueue(item);
                }
                catch (Exception e)
                {
                    // Probably a serialization exception
                    m_log.WarnFormat("ThrottleCheck: {0}", e.ToString());
                }
                finally
                {
                    Monitor.Pulse(this);
                    Monitor.Exit(this);
                }
            }
            else
            {
                q.Enqueue(item);
            }
        }
Ejemplo n.º 2
0
        public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings)
        {
            // While working on this, the BlockingQueue had me fooled for a bit.
            // The Blocking queue causes the thread to stop until there's something
            // in it to process.  it's an on-purpose threadlock though because
            // without it, the clientloop will suck up all sim resources.

            SendQueue = new OpenSim.Framework.BlockingQueue<LLQueItem>();

            IncomingPacketQueue = new Queue<LLQueItem>();
            OutgoingPacketQueue = new Queue<LLQueItem>();
            ResendOutgoingPacketQueue = new Queue<LLQueItem>();
            LandOutgoingPacketQueue = new Queue<LLQueItem>();
            WindOutgoingPacketQueue = new Queue<LLQueItem>();
            CloudOutgoingPacketQueue = new Queue<LLQueItem>();
            TaskOutgoingPacketQueue = new Queue<LLQueItem>();
            TaskLowpriorityPacketQueue = new Queue<LLQueItem>();
            TextureOutgoingPacketQueue = new Queue<LLQueItem>();
            AssetOutgoingPacketQueue = new Queue<LLQueItem>();

            // Store the throttle multiplier for posterity.
            throttleMultiplier = userSettings.ClientThrottleMultipler;

            // Set up the throttle classes (min, max, current) in bits per second
            ResendThrottle =    new LLPacketThrottle(5000, 100000, 16000, userSettings.ClientThrottleMultipler);
            LandThrottle =      new LLPacketThrottle(1000, 100000, 2000, userSettings.ClientThrottleMultipler);
            WindThrottle =      new LLPacketThrottle(0, 100000, 0, userSettings.ClientThrottleMultipler);
            CloudThrottle =     new LLPacketThrottle(0, 100000, 0, userSettings.ClientThrottleMultipler);
            TaskThrottle =      new LLPacketThrottle(1000, 800000, 3000, userSettings.ClientThrottleMultipler);
            AssetThrottle =     new LLPacketThrottle(1000, 800000, 1000, userSettings.ClientThrottleMultipler);
            TextureThrottle =   new LLPacketThrottle(1000, 800000, 4000, userSettings.ClientThrottleMultipler);
            
            // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second.            
            ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings;
            if (null == totalThrottleSettings)
            {                
                totalThrottleSettings = new ThrottleSettings(0, 1500000, 28000);
            }
            
            TotalThrottle 
                = new LLPacketThrottle(
                    totalThrottleSettings.Min, totalThrottleSettings.Max, totalThrottleSettings.Current,
                    userSettings.ClientThrottleMultipler);

            throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor));
            throttleTimer.Elapsed += ThrottleTimerElapsed;
            throttleTimer.Start();

            // TIMERS needed for this
            // LastThrottle = DateTime.Now.Ticks;
            // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor);

            m_agentId = agentId;

            if (StatsManager.SimExtraStats != null)
            {
                StatsManager.SimExtraStats.RegisterPacketQueueStatsProvider(m_agentId, this);
            }
        }