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;
                }
            }
        }
 private static int GetDatabaseThreadLimitAndHealth(Guid databaseGuid, out int databaseHealthMeasure, out List <KeyValuePair <string, double> > monitorHealthValues)
 {
     if (!DeliveryConfiguration.Instance.Throttling.MailboxDeliveryThrottlingEnabled)
     {
         databaseHealthMeasure = -1;
         monitorHealthValues   = null;
         return(DeliveryConfiguration.Instance.Throttling.MaxMailboxDeliveryPerMdbConnections);
     }
     DeliveryThrottling.Instance.TryGetDatabaseHealth(databaseGuid, out databaseHealthMeasure, out monitorHealthValues);
     return(DeliveryThrottling.GetDatabaseThreadLimit(databaseHealthMeasure, databaseGuid));
 }
        public void DecrementCurrentMessageSize(long smtpSessionId)
        {
            ThrottleSession throttleSession = DeliveryThrottling.sessionMap.TryGetSession(smtpSessionId);

            if (throttleSession != null)
            {
                lock (DeliveryThrottling.syncMessageSize)
                {
                    DeliveryThrottling.DecrementSessionMessageSize(throttleSession);
                }
            }
        }
        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;
            }
        }