private void IOError(Exception exception, bool willThrow)
{
GlobalLog.Enter("ConnectStream#" + ValidationHelper.HashString(this) + "::IOError", "Connection# " + ValidationHelper.HashString(m_Connection));
GlobalLog.ThreadContract(ThreadKinds.Unknown, "ConnectStream#" + ValidationHelper.HashString(this) + "::IOError");
string Msg;
if (m_ErrorException == null)
{
if ( exception == null ) {
if ( !WriteStream ) {
Msg = SR.GetString(SR.net_io_readfailure, SR.GetString(SR.net_io_connectionclosed));
}
else {
Msg = SR.GetString(SR.net_io_writefailure, SR.GetString(SR.net_io_connectionclosed));
}
Interlocked.CompareExchange<Exception>(ref m_ErrorException, new IOException(Msg), null);
}
else
{
willThrow &= Interlocked.CompareExchange<Exception>(ref m_ErrorException, exception, null) != null;
}
}
m_ChunkEofRecvd = true;
ConnectionReturnResult returnResult = null;
if (WriteStream)
m_Connection.HandleConnectStreamException(true, false, WebExceptionStatus.SendFailure, ref returnResult, m_ErrorException);
else
m_Connection.HandleConnectStreamException(false, true, WebExceptionStatus.ReceiveFailure, ref returnResult, m_ErrorException);
CallDone(returnResult);
GlobalLog.Leave("ConnectStream#" + ValidationHelper.HashString(this) + "::IOError");
if (willThrow)
{
throw m_ErrorException;
}
}