コード例 #1
0
        public bool CheckAndTrackThrottleConcurrentMessageSizeLimit(long smtpSessionId, int numOfRecipients)
        {
            ThrottleSession throttleSession = DeliveryThrottling.sessionMap.TryGetSession(smtpSessionId);
            bool            flag            = false;

            if (throttleSession != null && throttleSession.MessageSize >= 0L)
            {
                ulong num = Convert.ToUInt64(throttleSession.MessageSize);
                lock (DeliveryThrottling.syncMessageSize)
                {
                    if (DeliveryThrottling.totalConcurrentMessageSize < DeliveryThrottling.maxConcurrentMessageSizeLimit)
                    {
                        DeliveryThrottling.totalConcurrentMessageSize += num;
                        flag = true;
                    }
                    else
                    {
                        throttleSession.MessageSize = 0L;
                    }
                }
            }
            if (!flag)
            {
                DeliveryThrottling.Diag.TraceDebug <long, ulong>(0L, "Delivery for smtp session \"{0}\" is skipped as it exceeds max concurrent message size limit of {1}", smtpSessionId, DeliveryThrottling.maxConcurrentMessageSizeLimit);
                this.DeliveryThrottlingLogWorker.TrackConcurrentMessageSizeThrottle(true, DeliveryThrottling.maxConcurrentMessageSizeLimit, numOfRecipients);
            }
            else
            {
                this.DeliveryThrottlingLogWorker.TrackConcurrentMessageSizeThrottle(false, DeliveryThrottling.maxConcurrentMessageSizeLimit, numOfRecipients);
            }
            return(flag);
        }
コード例 #2
0
        public void ResetSession(long smtpSessionId)
        {
            ThrottleSession throttleSession = DeliveryThrottling.sessionMap.TryGetSession(smtpSessionId);

            if (throttleSession != null)
            {
                if (throttleSession.Recipients != null)
                {
                    IList <RoutingAddress> list = throttleSession.Recipients.Keys.ToList <RoutingAddress>();
                    foreach (RoutingAddress routingAddress in list)
                    {
                        int num = throttleSession.Recipients[routingAddress];
                        for (int i = 0; i < num; i++)
                        {
                            this.DecrementRecipient(smtpSessionId, routingAddress);
                        }
                    }
                }
                lock (DeliveryThrottling.syncMessageSize)
                {
                    DeliveryThrottling.DecrementSessionMessageSize(throttleSession);
                }
                if (throttleSession.Mdb != null)
                {
                    DeliveryThrottling.deliveryDatabaseThreadMap.Decrement(throttleSession.Mdb.ToString());
                    throttleSession.Mdb = null;
                }
            }
        }
コード例 #3
0
        public void ClearSession(long smtpSessionId)
        {
            ThrottleSession throttleSession = DeliveryThrottling.sessionMap.TryGetSession(smtpSessionId);

            if (throttleSession != null)
            {
                this.ResetSession(smtpSessionId);
                DeliveryThrottling.sessionMap.RemoveSession(smtpSessionId);
                DeliveryThrottling.deliveryServerThreadMap.Decrement("localhost");
            }
        }
コード例 #4
0
        public void DecrementCurrentMessageSize(long smtpSessionId)
        {
            ThrottleSession throttleSession = DeliveryThrottling.sessionMap.TryGetSession(smtpSessionId);

            if (throttleSession != null)
            {
                lock (DeliveryThrottling.syncMessageSize)
                {
                    DeliveryThrottling.DecrementSessionMessageSize(throttleSession);
                }
            }
        }
コード例 #5
0
        private static void DecrementSessionMessageSize(ThrottleSession session)
        {
            ulong num = Convert.ToUInt64(session.MessageSize);

            if (DeliveryThrottling.totalConcurrentMessageSize >= num)
            {
                DeliveryThrottling.totalConcurrentMessageSize -= num;
            }
            else
            {
                DeliveryThrottling.totalConcurrentMessageSize = 0UL;
            }
            session.MessageSize = 0L;
        }
コード例 #6
0
        public void SetSessionMessageSize(long messageSize, long smtpSessionId)
        {
            ThrottleSession throttleSession = DeliveryThrottling.sessionMap.TryGetSession(smtpSessionId);

            if (throttleSession != null)
            {
                DeliveryThrottling.DecrementSessionMessageSize(throttleSession);
                if (messageSize < 0L)
                {
                    messageSize = 0L;
                }
                throttleSession.MessageSize = messageSize;
            }
        }