// Called on Libuv thread
        public virtual void OnSocketClosed()
        {
            if (_filteredStreamAdapter != null)
            {
                _filteredStreamAdapter.Abort();
                _rawSocketInput.IncomingFin();
                _readInputTask.ContinueWith((task, state) =>
                {
                    ((Connection)state)._filterContext.Connection.Dispose();
                    ((Connection)state)._filteredStreamAdapter.Dispose();
                    ((Connection)state)._rawSocketInput.Dispose();
                }, this);
            }
            else
            {
                _rawSocketInput.Dispose();
            }

            lock (_stateLock)
            {
                _connectionState = ConnectionState.SocketClosed;

                if (_socketClosedTcs != null)
                {
                    // This is always waited on synchronously, so it's safe to
                    // call on the libuv thread.
                    _socketClosedTcs.TrySetResult(null);
                }
            }
        }
Пример #2
0
        // Called on Libuv thread
        public virtual void OnSocketClosed()
        {
            _frame.FrameStartedTask.ContinueWith((task, state) =>
            {
                var connection = (Connection)state;

                if (_filteredStreamAdapter != null)
                {
                    Task.WhenAll(_readInputTask, _frame.StopAsync()).ContinueWith((task2, state2) =>
                    {
                        var connection2 = (Connection)state2;
                        connection2._filterContext.Connection.Dispose();
                        connection2._filteredStreamAdapter.Dispose();
                    }, connection);
                }
            }, this);

            SocketInput.Dispose();
            _socketClosedTcs.TrySetResult(null);
        }