fixes bug 195746 "Corrupt cache / HTTP networking - Wrong images, incomplete

pages, octet-stream download dialog" r=dougt sr=bz
This commit is contained in:
darin%netscape.com 2003-03-25 02:23:11 +00:00
Родитель dd33629359
Коммит e9487262ed
4 изменённых файлов: 42 добавлений и 8 удалений

Просмотреть файл

@ -83,6 +83,7 @@ nsHttpPipeline::nsHttpPipeline()
, mStatus(NS_OK)
, mRequestIsPartial(PR_FALSE)
, mResponseIsPartial(PR_FALSE)
, mClosed(PR_FALSE)
, mPushBackBuf(nsnull)
, mPushBackLen(0)
, mPushBackMax(0)
@ -200,8 +201,12 @@ nsHttpPipeline::CloseTransaction(nsAHttpTransaction *trans, nsresult reason)
trans->Close(reason);
NS_RELEASE(trans);
if (killPipeline)
Close(reason);
if (killPipeline) {
if (mConnection)
mConnection->CloseTransaction(this, reason);
else
Close(reason);
}
}
void
@ -361,8 +366,13 @@ nsHttpPipeline::ReadSegments(nsAHttpSegmentReader *reader,
LOG(("nsHttpPipeline::ReadSegments [this=%x count=%u]\n", this, count));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
nsresult rv;
if (mClosed) {
*countRead = 0;
return mStatus;
}
nsresult rv;
PRUint32 avail = 0;
if (mSendBufIn) {
rv = mSendBufIn->Available(&avail);
@ -404,6 +414,9 @@ nsHttpPipeline::WriteSegments(nsAHttpSegmentWriter *writer,
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
if (mClosed)
return NS_SUCCEEDED(mStatus) ? NS_BASE_STREAM_CLOSED : mStatus;
nsAHttpTransaction *trans;
nsresult rv;
@ -453,8 +466,14 @@ nsHttpPipeline::Close(nsresult reason)
{
LOG(("nsHttpPipeline::Close [this=%x reason=%x]\n", this, reason));
if (mClosed) {
LOG((" already closed\n"));
return;
}
// the connection is going away!
mStatus = reason;
mClosed = PR_TRUE;
// we must no longer reference the connection!
NS_IF_RELEASE(mConnection);

Просмотреть файл

@ -104,8 +104,11 @@ private:
// is partial. a partial request means that Request(0) has been
// partially written out to the socket. a partial response means
// that Response(0) has been partially read in from the socket.
PRBool mRequestIsPartial;
PRBool mResponseIsPartial;
PRPackedBool mRequestIsPartial;
PRPackedBool mResponseIsPartial;
// indicates whether or not the pipeline has been explicitly closed.
PRPackedBool mClosed;
// used when calling ReadSegments/WriteSegments on a transaction.
nsAHttpSegmentReader *mReader;

Просмотреть файл

@ -123,6 +123,7 @@ nsHttpTransaction::nsHttpTransaction()
, mNoContent(PR_FALSE)
, mReceivedData(PR_FALSE)
, mDestroying(PR_FALSE)
, mClosed(PR_FALSE)
{
LOG(("Creating nsHttpTransaction @%x\n", this));
}
@ -326,6 +327,11 @@ nsHttpTransaction::ReadSegments(nsAHttpSegmentReader *reader,
{
NS_ASSERTION(PR_CurrentThread() == gSocketThread, "wrong thread");
if (mTransactionDone) {
*countRead = 0;
return mStatus;
}
if (!mConnected) {
mConnected = PR_TRUE;
mConnection->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
@ -350,7 +356,7 @@ nsHttpTransaction::WritePipeSegment(nsIOutputStream *stream,
nsHttpTransaction *trans = (nsHttpTransaction *) closure;
if (trans->mTransactionDone)
return NS_BASE_STREAM_CLOSED;
return NS_BASE_STREAM_CLOSED; // stop iterating
nsresult rv;
//
@ -378,7 +384,7 @@ nsHttpTransaction::WriteSegments(nsAHttpSegmentWriter *writer,
NS_ASSERTION(PR_CurrentThread() == gSocketThread, "wrong thread");
if (mTransactionDone)
return NS_BASE_STREAM_CLOSED;
return NS_SUCCEEDED(mStatus) ? NS_BASE_STREAM_CLOSED : mStatus;
mWriter = writer;
@ -400,7 +406,7 @@ nsHttpTransaction::Close(nsresult reason)
NS_ASSERTION(PR_CurrentThread() == gSocketThread, "wrong thread");
if (NS_FAILED(mStatus)) {
if (mClosed) {
LOG((" already closed\n"));
return;
}
@ -438,6 +444,7 @@ nsHttpTransaction::Close(nsresult reason)
mTransactionDone = PR_TRUE; // force this flag
mStatus = reason;
mClosed = PR_TRUE;
mPipeOut->CloseEx(reason);
}

Просмотреть файл

@ -205,6 +205,11 @@ private:
PRPackedBool mNoContent; // expecting an empty entity body?
PRPackedBool mReceivedData;
PRPackedBool mDestroying;
PRPackedBool mClosed;
// mClosed := transaction has been explicitly closed
// mTransactionDone := transaction ran to completion or was interrupted
// mResponseComplete := transaction ran to completion
};
#endif // nsHttpTransaction_h__