public void OnClose()
        {
            if (isServiceActive)
            {
                isServiceActive = false;
                try
                {
                    service.OnTerminate(this);
                }
                catch (Exception ex)
                {
                    ctx.CountedErrorHandler().OnError(ex);
                }
            }

            if (!ctx.OwnsAeronClient())
            {
                foreach (ClientSession session in sessionByIdMap.Values)
                {
                    session.Disconnect();
                }

                logAdapter?.Dispose();
                _consensusModuleProxy?.Dispose();
                _serviceAdapter?.Dispose();
            }

            ctx.Dispose();
        }
Beispiel #2
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();
        }