Esempio n. 1
0
        public void Shutdown(Action <StreamHandle, Exception> completion = null)
        {
            if (!this.IsValid)
            {
                return;
            }

            StreamShutdown streamShutdown = null;

            try
            {
                streamShutdown = new StreamShutdown(this, completion);
            }
            catch (Exception exception)
            {
                Exception error = exception;

                ErrorCode?errorCode = (error as OperationException)?.ErrorCode;
                if (errorCode == ErrorCode.EPIPE)
                {
                    // It is ok if the stream is already down
                    error = null;
                }
                if (error != null)
                {
                    Log.Error($"{this.HandleType} {this.InternalHandle} failed to shutdown.", error);
                }

                StreamShutdown.Completed(completion, this, error);
                streamShutdown?.Dispose();
            }
        }
Esempio n. 2
0
        protected internal void ShutdownStream(Action <StreamHandle, Exception> completion = null)
        {
            if (!this.IsValid ||
                !this.IsActive)
            {
                return;
            }

            StreamShutdown streamShutdown = null;

            try
            {
                streamShutdown = new StreamShutdown(this, completion);
            }
            catch (Exception exception)
            {
                Exception error = exception;

                int?errorCode = (error as OperationException)?.ErrorCode;
                if (errorCode == (int)uv_err_code.UV_EPIPE)
                {
                    // It is ok if the stream is already down
                    error = null;
                }
                Log.Error($"{this.HandleType} {this.InternalHandle} failed to shutdown.", error);

                StreamShutdown.Completed(completion, this, error);
                streamShutdown?.Dispose();
            }
        }