Beispiel #1
0
        public void OnClose()
        {
            aeron.RemoveCloseHandler(abortHandler);

            if (isAbort)
            {
                ctx.AbortLatch().Signal();
            }
            else
            {
                ErrorHandler errorHandler = ctx.CountedErrorHandler().OnError;

                if (isServiceActive)
                {
                    isServiceActive = false;
                    try
                    {
                        service.OnTerminate(this);
                    }
                    catch (Exception ex)
                    {
                        errorHandler(ex);
                    }
                }

                if (!ctx.OwnsAeronClient() && !aeron.IsClosed)
                {
                    foreach (var session in sessionByIdMap.Values)
                    {
                        session.Disconnect(errorHandler);
                    }


                    CloseHelper.Dispose(errorHandler, logAdapter);
                    CloseHelper.Dispose(errorHandler, _serviceAdapter);
                    CloseHelper.Dispose(errorHandler, _consensusModuleProxy);
                }
            }

            ctx.Dispose();
        }