Пример #1
0
        private void ShutdownCallback(UvShutdownRequest request, Exception error, object closingStateObject)
        {
            var closingState = (ClosingState)closingStateObject;

            try
            {
                if (error != null)
                {
                    throw error;
                }
            }
            catch (UvErrorException e)
            {
                if (e.ErrorCode != UvErrorCode.ECONNRESET)
                {
                    closingState.RegisterException(e);
                }
            }
            catch (Exception e)
            {
                closingState.RegisterException(e);
            }

            try
            {
                this.BaseSocket.Close();
            }
            catch (Exception e)
            {
                closingState.RegisterException(e);
            }

            this.InvokeClosedEvent(closingState.GetException());
        }
Пример #2
0
        private void CloseCallback(object closingStateObject)
        {
            var closingState = (ClosingState)closingStateObject;

            // Stop reading process (if any)
            try
            {
                this.BaseSocket.ReadStop();
            }
            catch (Exception exception)
            {
                closingState.RegisterException(exception);
            }

            // Clear receive state and free the receive buffer
            var state = this.receiveState;

            this.receiveState = null;

            // Return acquired buffer to the pool
            state?.Buffer?.Dispose();

            // Shut down any writing operations
            // Handle will be closed after the shutdown process
            var shutdownRequest = new UvShutdownRequest(this.BaseSocket, this.ShutdownCallback, closingState);

            try
            {
                shutdownRequest.Shutdown();
            }
            catch (Exception exception)
            {
                this.ShutdownCallback(shutdownRequest, exception, closingState);
            }
        }
Пример #3
0
 public static extern int uv_shutdown(UvShutdownRequest req, UvStream handle, UvShutdownCallback cb);