DataStreamClosed() 개인적인 메소드

private DataStreamClosed ( CloseExState closeState ) : void
closeState CloseExState
리턴 void
        void ICloseEx.CloseEx(CloseExState closeState)
        {
            GlobalLog.Print("FtpDataStream#" + ValidationHelper.HashString(this) + "::CloseEx, state = " + closeState.ToString());

            lock (this)
            {
                if (m_Closing == true)
                {
                    return;
                }
                m_Closing   = true;
                m_Writeable = false;
                m_Readable  = false;
            }

            try {
                try {
                    if ((closeState & CloseExState.Abort) == 0)
                    {
                        m_NetworkStream.Close(Socket.DefaultCloseTimeout);
                    }
                    else
                    {
                        m_NetworkStream.Close(0);
                    }
                } finally {
                    m_Request.DataStreamClosed(closeState);
                }
            }
            catch (Exception exception) {
                bool         doThrow      = true;
                WebException webException = exception as WebException;
                if (webException != null)
                {
                    FtpWebResponse response = webException.Response as FtpWebResponse;
                    if (response != null)
                    {
                        if (!m_IsFullyRead &&
                            response.StatusCode == FtpStatusCode.ConnectionClosed)
                        {
                            doThrow = false;
                        }
                    }
                }

                if (doThrow)
                {
                    if ((closeState & CloseExState.Silent) == 0)
                    {
                        throw;
                    }
                }
            }
        }
예제 #2
0
        void ICloseEx.CloseEx(CloseExState closeState)
        {
            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"state = {closeState}");

            lock (this)
            {
                if (_closing == true)
                    return;
                _closing = true;
                _writeable = false;
                _readable = false;
            }

            try
            {
                try
                {
                    if ((closeState & CloseExState.Abort) == 0)
                        _networkStream.Close(DefaultCloseTimeout);
                    else
                        _networkStream.Close(0);
                }
                finally
                {
                    _request.DataStreamClosed(closeState);
                }
            }
            catch (Exception exception)
            {
                bool doThrow = true;
                WebException webException = exception as WebException;
                if (webException != null)
                {
                    FtpWebResponse response = webException.Response as FtpWebResponse;
                    if (response != null)
                    {
                        if (!_isFullyRead
                            && response.StatusCode == FtpStatusCode.ConnectionClosed)
                            doThrow = false;
                    }
                }

                if (doThrow)
                    if ((closeState & CloseExState.Silent) == 0)
                        throw;
            }
        }
예제 #3
0
        void ICloseEx.CloseEx(CloseExState closeState)
        {
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Print("FtpDataStream#" + LoggingHash.HashString(this) + "::CloseEx, state = " + closeState.ToString());
            }

            lock (this)
            {
                if (_closing == true)
                {
                    return;
                }
                _closing   = true;
                _writeable = false;
                _readable  = false;
            }

            try
            {
                try
                {
                    if ((closeState & CloseExState.Abort) == 0)
                    {
                        _networkStream.Close(DefaultCloseTimeout);
                    }
                    else
                    {
                        _networkStream.Close(0);
                    }
                }
                finally
                {
                    _request.DataStreamClosed(closeState);
                }
            }
            catch (Exception exception)
            {
                bool         doThrow      = true;
                WebException webException = exception as WebException;
                if (webException != null)
                {
                    FtpWebResponse response = webException.Response as FtpWebResponse;
                    if (response != null)
                    {
                        if (!_isFullyRead &&
                            response.StatusCode == FtpStatusCode.ConnectionClosed)
                        {
                            doThrow = false;
                        }
                    }
                }

                if (doThrow)
                {
                    if ((closeState & CloseExState.Silent) == 0)
                    {
                        throw;
                    }
                }
            }
        }