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); } } }
internal void Apply(UrlGroup urlGroup, RequestQueue requestQueue) { _urlGroup = urlGroup; _requestQueue = requestQueue; if (_maxConnections.HasValue) { _urlGroup.SetMaxConnections(_maxConnections.Value); } if (_requestQueueLength != DefaultRequestQueueLength) { _requestQueue.SetLengthLimit(_requestQueueLength); } }
internal RequestQueue(UrlGroup urlGroup) { _urlGroup = urlGroup; var queueName = "IISConsole"; HttpRequestQueueV2Handle requestQueueHandle = null; var statusCode = HttpApi.HttpCreateRequestQueue( HttpApi.Version, queueName, null, HttpApiTypes.HTTP_CREATE_REQUEST_QUEUE_FLAGS.HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER, out requestQueueHandle); if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS) { throw new HttpSysException((int)statusCode); } Handle = requestQueueHandle; BoundHandle = ThreadPoolBoundHandle.BindHandle(Handle); }
private void DisposeInternal() { _pipeServer.Dispose(); // V2 stopping sequence: // 1. Detach request queue from url group - Done in Stop()/Abort() // 2. Remove urls from url group - Done in Stop() // 3. Close request queue - Done in Stop()/Abort() // 4. Close Url group. // 5. Close server session. RequestQueue.Dispose(); UrlGroup.Dispose(); Debug.Assert(ServerSession != null, "ServerSessionHandle is null in CloseV2Config"); Debug.Assert(!ServerSession.Id.IsInvalid, "ServerSessionHandle is invalid in CloseV2Config"); ServerSession.Dispose(); }
public void Start() { // 1. Create Http.Sys queue try { ServerSession = new ServerSession(); UrlGroup = new UrlGroup(ServerSession); RequestQueue = new RequestQueue(UrlGroup); } catch (Exception) { // If Url group or request queue creation failed, close server session before throwing. RequestQueue?.Dispose(); UrlGroup?.Dispose(); ServerSession?.Dispose(); throw; } // 2. Attach request queue to url group lock (_internalLock) { try { CheckDisposed(); if (_state == State.Started) { return; } Options.Apply(UrlGroup, RequestQueue); RequestQueue.AttachToUrlGroup(); // 3. Register url prefixes try { Options.UrlPrefixes.RegisterAllPrefixes(UrlGroup); } catch (HttpSysException) { RequestQueue.DetachFromUrlGroup(); throw; } } catch (Exception) { _state = State.Disposed; DisposeInternal(); throw; } } // 4. Listen on named pipe _pipeServer.StartServer(); // 5. Start Process _process.StartInfo.FileName = _w3wpPath; _process.StartInfo.Arguments = _w3wpArguments; _process.StartInfo.UseShellExecute = false; _process.StartInfo.CreateNoWindow = true; _process.Start(); // TODO // Start process in suspended mode, add to job object, and then resume ChildProcessTracker.AddProcess(_process); }