private void HandleError(bool writeDone, bool readDone, WebExceptionStatus webExceptionStatus, ref ConnectionReturnResult returnResult)
{
lock(this)
{
if (writeDone)
m_WriteDone = true;
if (readDone)
m_ReadDone = true;
GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::HandleError() m_WriteList.Count:" + m_WriteList.Count +
" m_WaitList.Count:" + m_WaitList.Count +
" new WriteDone:" + m_WriteDone + " new ReadDone:" + m_ReadDone);
GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::HandleError() current HttpWebRequest#" + ValidationHelper.HashString(m_CurrentRequest));
if(webExceptionStatus == WebExceptionStatus.Success)
throw new InternalException(); //consider making an assert later.
m_Error = webExceptionStatus;
PrepareCloseConnectionSocket(ref returnResult);
// This will kill the socket
// Must be done inside the lock. (Stream Close() isn't threadsafe.)
Close(0);
}
}