コード例 #1
0
        internal unsafe UrlGroup(ServerSession serverSession)
        {
            _serverSession = serverSession;

            ulong urlGroupId = 0;
            var   statusCode = HttpApi.HttpCreateUrlGroup(
                _serverSession.Id.DangerousGetServerSessionId(), &urlGroupId, 0);

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

            Debug.Assert(urlGroupId != 0, "Invalid id returned by HttpCreateUrlGroup");
            Id = urlGroupId;
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
        }