Ejemplo n.º 1
0
        /// <summary>
        /// Called on libuv thread.
        /// </summary>
        internal 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)
            {
                State = ConnectionState.SocketClosed;

                if (_socketClosedTcs != null)
                {
                    // This is always waited on synchronously, so it's safe to
                    // call on the libuv thread.
                    _socketClosedTcs.TrySetResult(null);
                }
            }

            // We're already in the libuv thread, simply abort the processing
            AbortProcessing();
        }
Ejemplo n.º 2
0
        private void OnStreamClose(Task copyAsyncTask)
        {
            _memory.Return(_block);

            if (copyAsyncTask.IsFaulted)
            {
                SocketInput.AbortAwaiting();
                Service.Logger.Log(copyAsyncTask.Exception);
            }
            else if (copyAsyncTask.IsCanceled)
            {
                SocketInput.AbortAwaiting();
                Service.Logger.Log(LogLevel.Error, "FilteredStreamAdapter.CopyToAsync canceled.");
            }
            else if (_aborted)
            {
                SocketInput.AbortAwaiting();
            }

            try
            {
                SocketInput.IncomingFin();
            }
            catch (Exception ex)
            {
                Service.Logger.Log(ex);
            }
        }
Ejemplo n.º 3
0
        private void OnStreamClose(Task copyAsyncTask)
        {
            _memory.Return(_block);

            if (copyAsyncTask.IsFaulted)
            {
                SocketInput.AbortAwaiting();
                _log.LogError(0, copyAsyncTask.Exception, "FilteredStreamAdapter.CopyToAsync");
            }
            else if (copyAsyncTask.IsCanceled)
            {
                SocketInput.AbortAwaiting();
                _log.LogError("FilteredStreamAdapter.CopyToAsync canceled.");
            }
            else if (_aborted)
            {
                SocketInput.AbortAwaiting();
            }

            try
            {
                SocketInput.IncomingFin();
            }
            catch (Exception ex)
            {
                _log.LogError(0, ex, "FilteredStreamAdapter.OnStreamClose");
            }
        }
 protected override void Dispose(bool disposing)
 {
     // Close _socketInput with a fake zero-length write that will result in a zero-length read.
     _socketInput.IncomingFin();
     base.Dispose(disposing);
 }