示例#1
0
        internal RequestQueue(UrlGroup urlGroup, ILogger logger)
        {
            _urlGroup = urlGroup;
            _logger   = logger;

            HttpRequestQueueV2Handle requestQueueHandle = null;
            var statusCode = HttpApi.HttpCreateRequestQueue(
                HttpApi.Version, null, null, 0, out requestQueueHandle);

            if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
            {
                throw new HttpSysException((int)statusCode);
            }

            // Disabling callbacks when IO operation completes synchronously (returns ErrorCodes.ERROR_SUCCESS)
            if (HttpSysListener.SkipIOCPCallbackOnSuccess &&
                !UnsafeNclNativeMethods.SetFileCompletionNotificationModes(
                    requestQueueHandle,
                    UnsafeNclNativeMethods.FileCompletionNotificationModes.SkipCompletionPortOnSuccess |
                    UnsafeNclNativeMethods.FileCompletionNotificationModes.SkipSetEventOnHandle))
            {
                throw new HttpSysException(Marshal.GetLastWin32Error());
            }

            Handle      = requestQueueHandle;
            BoundHandle = ThreadPoolBoundHandle.BindHandle(Handle);
        }
示例#2
0
        public HttpSysListener(HttpSysOptions options, ILoggerFactory loggerFactory)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (!HttpApi.Supported)
            {
                throw new PlatformNotSupportedException();
            }

            Debug.Assert(HttpApi.ApiVersion == HttpApiTypes.HTTP_API_VERSION.Version20, "Invalid Http api version");

            Options = options;

            Logger = LogHelper.CreateLogger(loggerFactory, typeof(HttpSysListener));

            _state        = State.Stopped;
            _internalLock = new object();

            // V2 initialization sequence:
            // 1. Create server session
            // 2. Create url group
            // 3. Create request queue - Done in Start()
            // 4. Add urls to url group - Done in Start()
            // 5. Attach request queue to url group - Done in Start()

            try
            {
                _serverSession = new ServerSession();

                _urlGroup = new UrlGroup(_serverSession, Logger);

                _requestQueue = new RequestQueue(_urlGroup, Logger);

                _disconnectListener = new DisconnectListener(_requestQueue, Logger);
            }
            catch (Exception exception)
            {
                // If Url group or request queue creation failed, close server session before throwing.
                _requestQueue?.Dispose();
                _urlGroup?.Dispose();
                _serverSession?.Dispose();
                LogHelper.LogException(Logger, ".Ctor", exception);
                throw;
            }
        }
示例#3
0
 internal void RegisterAllPrefixes(UrlGroup urlGroup)
 {
     lock (_prefixes)
     {
         _urlGroup = urlGroup;
         // go through the uri list and register for each one of them
         foreach (var pair in _prefixes)
         {
             // We'll get this index back on each request and use it to look up the prefix to calculate PathBase.
             _urlGroup.RegisterPrefix(pair.Value.FullPrefix, pair.Key);
         }
     }
 }
示例#4
0
 internal void SetUrlGroupSecurity(UrlGroup urlGroup)
 {
     Debug.Assert(_urlGroup == null, "SetUrlGroupSecurity called more than once.");
     _urlGroup = urlGroup;
     SetUrlGroupSecurity();
 }
示例#5
0
 internal void SetUrlGroupTimeouts(UrlGroup urlGroup)
 {
     _urlGroup = urlGroup;
     SetUrlGroupTimeouts(_timeouts, _minSendBytesPerSecond);
 }