SetServerTimeout() private method

private SetServerTimeout ( int timeouts, uint minSendBytesPerSecond ) : void
timeouts int
minSendBytesPerSecond uint
return void
Esempio n. 1
0
        // Initial values come from the config.  The values can then be overridden using this public API.
        private void LoadConfigurationSettings()
        {
            long[] configTimeouts = SettingsSectionInternal.Section.HttpListenerTimeouts;
            Debug.Assert(configTimeouts != null);
            Debug.Assert(configTimeouts.Length == (timeouts.Length + 1));

            bool setNonDefaults = false;

            for (int i = 0; i < timeouts.Length; i++)
            {
                if (configTimeouts[i] != 0)
                {
                    Debug.Assert(configTimeouts[i] <= ushort.MaxValue, "Timeout out of range: " + configTimeouts[i]);
                    timeouts[i]    = (int)configTimeouts[i];
                    setNonDefaults = true;
                }
            }

            if (configTimeouts[5] != 0)
            {
                Debug.Assert(configTimeouts[5] <= uint.MaxValue, "Timeout out of range: " + configTimeouts[5]);
                minSendBytesPerSecond = (uint)configTimeouts[5];
                setNonDefaults        = true;
            }

            if (setNonDefaults)
            {
                listener.SetServerTimeout(timeouts, minSendBytesPerSecond);
            }
        }
Esempio n. 2
0
        private void SetTimespanTimeout(Interop.HttpApi.HTTP_TIMEOUT_TYPE type, TimeSpan value)
        {
            long timeoutValue;

            //
            // All timeouts are defined as USHORT in native layer (except MinSendRate, which is ULONG). Make sure that
            // timeout value is within range.
            //
            timeoutValue = Convert.ToInt64(value.TotalSeconds);

            if (timeoutValue < 0 || timeoutValue > ushort.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(value));
            }

            //
            // Use local state to get values for other timeouts. Call into the native layer and if that
            // call succeeds, update local state.
            //

            int[] currentTimeouts = _timeouts;
            currentTimeouts[(int)type] = (int)timeoutValue;
            _listener.SetServerTimeout(currentTimeouts, _minSendBytesPerSecond);
            _timeouts[(int)type] = (int)timeoutValue;
        }