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 = loggerFactory.CreateLogger <HttpSysListener>(); _state = State.Stopped; _internalLock = new object(); // V2 initialization sequence: // 1. Create server session // 2. Create url group // 3. Create request queue // 4. Add urls to url group - Done in Start() // 5. Attach request queue to url group - Done in Start() try { _serverSession = new ServerSession(); _requestQueue = new RequestQueue(options.RequestQueueName, options.RequestQueueMode, Logger); _urlGroup = new UrlGroup(_serverSession, _requestQueue, 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(); Log.HttpSysListenerCtorError(Logger, exception); throw; } }
private void DisposeInternal() { // 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(); }
protected virtual void Dispose(bool disposing) { if (alreadyDisposed) { return; } if (disposing) { // dispose managed state (managed objects). m_server.Stop(); m_requestQueue.Dispose(); } // TODO: Set large fields to null. alreadyDisposed = true; }