Skip site navigation (1)Skip section navigation (2)
Date:      16 Apr 2003 13:36:31 -0400
From:      Joe Marcus Clarke <marcus@marcuscom.com>
To:        Gerard Samuel <gsam@trini0.org>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: Mozilla 1.3 wierdness, maybe a bug???
Message-ID:  <1050514591.606.46.camel@gyros>
In-Reply-To: <3E9C5F31.1020608@trini0.org>
References:  <3E9C5F31.1020608@trini0.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-HEI6OgAM8ONhUq2GxjCV
Content-Type: multipart/mixed; boundary="=-u42aHKURhXQyBz+jIhGL"


--=-u42aHKURhXQyBz+jIhGL
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Tue, 2003-04-15 at 15:36, Gerard Samuel wrote:
> Has anyone experienced unexpected output from mozilla 1.3 from the ports?=
?
> I had just upgraded earlier today from 1.2.x to 1.3 (after a fresh pull=20
> of the ports), and it seems as if after a redirection (via php),
> Im getting this unexpected output.
> It only started happening after I upgraded mozilla, and under the native=20
> opera port it is still working as expected.
> For an example of what I mean by "unexpected output" take a look at ->=20
> http://test1.trini0.org:81/mozilla.png
> Everything from the top of the page to the end of the headers are not=20
> supposed to be there...
>=20
> When I view the source of this page, the "unexpected output" isn't=20
> there, but the page as it is supposed to be.
> Im running KDE 3.1.1a, FreeBSD 5.  If you need more info, feel free to=20
> ask...

Maybe you can beat my build.  Give the attached patch a try, and let me
know if it works.  Thanks.

Joe

>=20
> Thanks
>=20
>=20
>=20
> _______________________________________________
> freebsd-gnome@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-gnome
> To unsubscribe, send any mail to "freebsd-gnome-unsubscribe@freebsd.org"
--=20
PGP Key : http://www.marcuscom.com/pgp.asc



--=-u42aHKURhXQyBz+jIhGL
Content-Disposition: attachment; filename=patch-corrupt-cache
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=patch-corrupt-cache; charset=ISO8859-1

Index: nsHttpPipeline.cpp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/mozilla/netwerk/protocol/http/src/nsHttpPipeline.cpp,v
retrieving revision 1.10
diff -u -2 -0 -r1.10 nsHttpPipeline.cpp
--- netwerk/protocol/http/src/nsHttpPipeline.cpp	9 Feb 2003 20:13:45 -0000	=
1.10
+++ netwerk/protocol/http/src/nsHttpPipeline.cpp	18 Mar 2003 22:32:39 -0000
@@ -66,40 +66,41 @@
         mBuf +=3D count;
         mBufLen -=3D count;
         *countWritten =3D count;
         return NS_OK;
     }
=20
 private:
     const char *mBuf;
     PRUint32    mBufLen;
 };
=20
 //------------------------------------------------------------------------=
-----
 // nsHttpPipeline <public>
 //------------------------------------------------------------------------=
-----
=20
 nsHttpPipeline::nsHttpPipeline()
     : mConnection(nsnull)
     , mStatus(NS_OK)
     , mRequestIsPartial(PR_FALSE)
     , mResponseIsPartial(PR_FALSE)
+    , mClosed(PR_FALSE)
     , mPushBackBuf(nsnull)
     , mPushBackLen(0)
     , mPushBackMax(0)
 {
 }
=20
 nsHttpPipeline::~nsHttpPipeline()
 {
     // make sure we aren't still holding onto any transactions!
     Close(NS_ERROR_ABORT);
=20
     if (mPushBackBuf)
         free(mPushBackBuf);
 }
=20
 nsresult
 nsHttpPipeline::AddTransaction(nsAHttpTransaction *trans)
 {
     LOG(("nsHttpPipeline::AddTransaction [this=3D%x trans=3D%x]\n", this, =
trans));
=20
@@ -344,42 +345,47 @@
 NS_METHOD
 nsHttpPipeline::ReadFromPipe(nsIInputStream *stream,
                              void *closure,
                              const char *buf,
                              PRUint32 offset,
                              PRUint32 count,
                              PRUint32 *countRead)
 {
     nsHttpPipeline *self =3D (nsHttpPipeline *) closure;
     return self->mReader->OnReadSegment(buf, count, countRead);
 }
=20
 nsresult
 nsHttpPipeline::ReadSegments(nsAHttpSegmentReader *reader,
                              PRUint32 count,
                              PRUint32 *countRead)
 {
     LOG(("nsHttpPipeline::ReadSegments [this=3D%x count=3D%u]\n", this, co=
unt));
=20
     NS_ASSERTION(PR_GetCurrentThread() =3D=3D gSocketThread, "wrong thread=
");
-    nsresult rv;
=20
+    if (mClosed) {
+        *countRead =3D 0;
+        return mStatus;
+    }
+
+    nsresult rv;
     PRUint32 avail =3D 0;
     if (mSendBufIn) {
         rv =3D mSendBufIn->Available(&avail);
         if (NS_FAILED(rv)) return rv;
     }
=20
     if (avail =3D=3D 0) {
         rv =3D FillSendBuf();
         if (NS_FAILED(rv)) return rv;
=20
         rv =3D mSendBufIn->Available(&avail);
         if (NS_FAILED(rv)) return rv;
=20
         // return EOF if send buffer is empty
         if (avail =3D=3D 0) {
             *countRead =3D 0;
             return NS_OK;
         }
     }
=20
@@ -387,40 +393,43 @@
     if (avail > count)
         avail =3D count;
=20
     mReader =3D reader;
=20
     rv =3D mSendBufIn->ReadSegments(ReadFromPipe, this, avail, countRead);
=20
     mReader =3D nsnull;
     return rv;
 }
=20
 nsresult
 nsHttpPipeline::WriteSegments(nsAHttpSegmentWriter *writer,
                               PRUint32 count,
                               PRUint32 *countWritten)
 {
     LOG(("nsHttpPipeline::WriteSegments [this=3D%x count=3D%u]\n", this, c=
ount));
=20
     NS_ASSERTION(PR_GetCurrentThread() =3D=3D gSocketThread, "wrong thread=
");
=20
+    if (mClosed)
+        return NS_SUCCEEDED(mStatus) ? NS_BASE_STREAM_CLOSED : mStatus;
+
     nsAHttpTransaction *trans;=20
     nsresult rv;
=20
     trans =3D Response(0);
     if (!trans) {
         if (mRequestQ.Count() > 0)
             rv =3D NS_BASE_STREAM_WOULD_BLOCK;
         else
             rv =3D NS_BASE_STREAM_CLOSED;
     }
     else {
         //=20
         // ask the transaction to consume data from the connection.
         // PushBack may be called recursively.
         //
         rv =3D trans->WriteSegments(writer, count, countWritten);
=20
         if (rv =3D=3D NS_BASE_STREAM_CLOSED || trans->IsDone()) {
             trans->Close(NS_OK);
             NS_RELEASE(trans);
@@ -436,42 +445,48 @@
     }
=20
     if (mPushBackLen) {
         nsHttpPushBackWriter writer(mPushBackBuf, mPushBackLen);
         PRUint32 len =3D mPushBackLen, n;
         mPushBackLen =3D 0;
         // the push back buffer is never larger than NS_HTTP_SEGMENT_SIZE,
         // so we are guaranteed that the next response will eat the entire
         // push back buffer (even though it might again call PushBack).
         rv =3D WriteSegments(&writer, len, &n);
     }
=20
     return rv;
 }
=20
 void
 nsHttpPipeline::Close(nsresult reason)
 {
     LOG(("nsHttpPipeline::Close [this=3D%x reason=3D%x]\n", this, reason))=
;
=20
+    if (mClosed) {
+        LOG(("  already closed\n"));
+        return;
+    }
+
     // the connection is going away!
     mStatus =3D reason;
+    mClosed =3D PR_TRUE;
=20
     // we must no longer reference the connection!
     NS_IF_RELEASE(mConnection);
=20
     PRUint32 i, count;
     nsAHttpTransaction *trans;
=20
     // any pending requests can ignore this error and be restarted
     count =3D mRequestQ.Count();
     for (i=3D0; i<count; ++i) {
         trans =3D Request(i);
         trans->Close(NS_ERROR_NET_RESET);
         NS_RELEASE(trans);
     }
     mRequestQ.Clear();
=20
     trans =3D Response(0);
     if (trans) {
         // if the current response is partially complete, then it cannot b=
e
         // restarted and will have to fail with the status of the connecti=
on.
Index: nsHttpPipeline.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/mozilla/netwerk/protocol/http/src/nsHttpPipeline.h,v
retrieving revision 1.3
diff -u -2 -0 -r1.3 nsHttpPipeline.h
--- netwerk/protocol/http/src/nsHttpPipeline.h	9 Feb 2003 20:13:45 -0000	1.=
3
+++ netwerk/protocol/http/src/nsHttpPipeline.h	18 Mar 2003 22:32:39 -0000
@@ -87,38 +87,41 @@
=20
         return (nsAHttpTransaction *) mRequestQ[i];
     }
     nsAHttpTransaction *Response(PRInt32 i)
     {
         if (mResponseQ.Count() =3D=3D 0)
             return nsnull;
=20
         return (nsAHttpTransaction *) mResponseQ[i];
     }
=20
     nsAHttpConnection *mConnection;
     nsVoidArray        mRequestQ;  // array of transactions
     nsVoidArray        mResponseQ; // array of transactions
     nsresult           mStatus;
=20
     // these flags indicate whether or not the first request or response
     // is partial.  a partial request means that Request(0) has been=20
     // 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;
=20
     // used when calling ReadSegments/WriteSegments on a transaction.
     nsAHttpSegmentReader *mReader;
     nsAHttpSegmentWriter *mWriter;
=20
     // send buffer
     nsCOMPtr<nsIInputStream>  mSendBufIn;
     nsCOMPtr<nsIOutputStream> mSendBufOut;
=20
     // the push back buffer.  not exceeding NS_HTTP_SEGMENT_SIZE bytes.
     char     *mPushBackBuf;
     PRUint32  mPushBackLen;
     PRUint32  mPushBackMax;
 };
=20
 #endif // nsHttpPipeline_h__
Index: nsHttpTransaction.cpp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/mozilla/netwerk/protocol/http/src/nsHttpTransaction.cpp,=
v
retrieving revision 1.64
diff -u -2 -0 -r1.64 nsHttpTransaction.cpp
--- netwerk/protocol/http/src/nsHttpTransaction.cpp	13 Mar 2003 00:52:39 -0=
000	1.64
+++ netwerk/protocol/http/src/nsHttpTransaction.cpp	18 Mar 2003 22:32:39 -0=
000
@@ -106,40 +106,41 @@
     , mContentLength(-1)
     , mContentRead(0)
     , mChunkedDecoder(nsnull)
     , mStatus(NS_OK)
     , mLock(PR_NewLock())
     , mTransportStatus(0)
     , mTransportProgress(0)
     , mTransportProgressMax(0)
     , mTransportStatusInProgress(PR_FALSE)
     , mRestartCount(0)
     , mCaps(0)
     , mConnected(PR_FALSE)
     , mHaveStatusLine(PR_FALSE)
     , mHaveAllHeaders(PR_FALSE)
     , mTransactionDone(PR_FALSE)
     , mResponseIsComplete(PR_FALSE)
     , mDidContentStart(PR_FALSE)
     , mNoContent(PR_FALSE)
     , mReceivedData(PR_FALSE)
     , mDestroying(PR_FALSE)
+    , mClosed(PR_FALSE)
 {
     LOG(("Creating nsHttpTransaction @%x\n", this));
 }
=20
 nsHttpTransaction::~nsHttpTransaction()
 {
     LOG(("Destroying nsHttpTransaction @%x\n", this));
=20
     NS_IF_RELEASE(mConnection);
     NS_IF_RELEASE(mConnInfo);
=20
     delete mResponseHead;
     delete mChunkedDecoder;
=20
     PR_DestroyLock(mLock);
 }
=20
 nsresult
 nsHttpTransaction::Init(PRUint8 caps,
                         nsHttpConnectionInfo *cinfo,
@@ -309,152 +310,158 @@
 }
=20
 NS_METHOD
 nsHttpTransaction::ReadRequestSegment(nsIInputStream *stream,
                                       void *closure,
                                       const char *buf,
                                       PRUint32 offset,
                                       PRUint32 count,
                                       PRUint32 *countRead)
 {
     nsHttpTransaction *trans =3D (nsHttpTransaction *) closure;
     return trans->mReader->OnReadSegment(buf, count, countRead);
 }
=20
 nsresult
 nsHttpTransaction::ReadSegments(nsAHttpSegmentReader *reader,
                                 PRUint32 count, PRUint32 *countRead)
 {
     NS_ASSERTION(PR_CurrentThread() =3D=3D gSocketThread, "wrong thread");
=20
+    if (mTransactionDone) {
+        *countRead =3D 0;
+        return mStatus;
+    }
+
     if (!mConnected) {
         mConnected =3D PR_TRUE;
         mConnection->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
     }
=20
     mReader =3D reader;
=20
     nsresult rv =3D mRequestStream->ReadSegments(ReadRequestSegment, this,=
 count, countRead);
=20
     mReader =3D nsnull;
     return rv;
 }
=20
 NS_METHOD
 nsHttpTransaction::WritePipeSegment(nsIOutputStream *stream,
                                     void *closure,
                                     char *buf,
                                     PRUint32 offset,
                                     PRUint32 count,
                                     PRUint32 *countWritten)
 {
     nsHttpTransaction *trans =3D (nsHttpTransaction *) closure;
=20
     if (trans->mTransactionDone)
-        return NS_BASE_STREAM_CLOSED;
+        return NS_BASE_STREAM_CLOSED; // stop iterating
=20
     nsresult rv;
     //
     // OK, now let the caller fill this segment with data.
     //
     rv =3D trans->mWriter->OnWriteSegment(buf, count, countWritten);
     if (NS_FAILED(rv)) return rv; // caller didn't want to write anything
=20
     NS_ASSERTION(*countWritten > 0, "bad writer");
     trans->mReceivedData =3D PR_TRUE;
=20
     // now let the transaction "play" with the buffer.  it is free to modi=
fy
     // the contents of the buffer and/or modify countWritten.
     rv =3D trans->ProcessData(buf, *countWritten, countWritten);
     if (NS_FAILED(rv))
         trans->Close(rv);
=20
     return rv; // failure code only stops WriteSegments; it is not propoga=
ted.
 }
=20
 nsresult
 nsHttpTransaction::WriteSegments(nsAHttpSegmentWriter *writer,
                                  PRUint32 count, PRUint32 *countWritten)
 {
     NS_ASSERTION(PR_CurrentThread() =3D=3D gSocketThread, "wrong thread");
=20
     if (mTransactionDone)
-        return NS_BASE_STREAM_CLOSED;
+        return NS_SUCCEEDED(mStatus) ? NS_BASE_STREAM_CLOSED : mStatus;
=20
     mWriter =3D writer;
=20
     nsresult rv =3D mPipeOut->WriteSegments(WritePipeSegment, this, count,=
 countWritten);
=20
     mWriter =3D nsnull;
=20
     // if pipe would block then we need to AsyncWait on it.
     if (rv =3D=3D NS_BASE_STREAM_WOULD_BLOCK)
         mPipeOut->AsyncWait(this, 0, nsnull);
=20
     return rv;
 }
=20
 void
 nsHttpTransaction::Close(nsresult reason)
 {
     LOG(("nsHttpTransaction::Close [this=3D%x reason=3D%x]\n", this, reaso=
n));
=20
     NS_ASSERTION(PR_CurrentThread() =3D=3D gSocketThread, "wrong thread");
=20
-    if (NS_FAILED(mStatus)) {
+    if (mClosed) {
         LOG(("  already closed\n"));
         return;
     }
=20
     // we must no longer reference the connection!  find out if the=20
     // connection was being reused before letting it go.
     PRBool connReused =3D PR_FALSE;
     if (mConnection) {
         connReused =3D mConnection->IsReused();
         NS_RELEASE(mConnection);
     }
     mConnected =3D PR_FALSE;
=20
     //
     // if the connection was reset or closed before we read any part of th=
e
     // response, and if the connection was being reused, then we can assum=
e
     // that we wrote to a stale connection and we must therefore repeat th=
e
     // request over a new connection.
     //
     if (!mReceivedData && connReused && (reason =3D=3D NS_ERROR_NET_RESET =
||
                                          reason =3D=3D NS_OK)) {
         // if restarting fails, then we must proceed to close the pipe,
         // which will notify the channel that the transaction failed.
         if (NS_SUCCEEDED(Restart()))
             return;
     }
=20
     if (NS_SUCCEEDED(reason) && !mHaveAllHeaders && !mLineBuf.IsEmpty()) {
         // the server has not sent the final \r\n terminating the header s=
ection,
         // and there is still a header line unparsed.  let's make sure we =
parse
         // the remaining header line, and then hopefully, the response wil=
l be
         // usable (see bug 88792).
         ParseLineSegment("\n", 1);
     }
=20
     mTransactionDone =3D PR_TRUE; // force this flag
     mStatus =3D reason;
+    mClosed =3D PR_TRUE;
=20
     mPipeOut->CloseEx(reason);
 }
=20
 //------------------------------------------------------------------------=
-----
 // nsHttpTransaction <private>
 //------------------------------------------------------------------------=
-----
=20
 nsresult
 nsHttpTransaction::Restart()
 {
     NS_ASSERTION(PR_GetCurrentThread() =3D=3D gSocketThread, "wrong thread=
");
=20
     // limit the number of restart attempts - bug 92224
     if (++mRestartCount >=3D gHttpHandler->MaxRequestAttempts()) {
         LOG(("reached max request attempts, failing transaction @%x\n", th=
is));
         return NS_ERROR_NET_RESET;
     }
=20
     LOG(("restarting transaction @%x\n", this));
Index: nsHttpTransaction.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/mozilla/netwerk/protocol/http/src/nsHttpTransaction.h,v
retrieving revision 1.30
diff -u -2 -0 -r1.30 nsHttpTransaction.h
--- netwerk/protocol/http/src/nsHttpTransaction.h	9 Feb 2003 20:13:46 -0000=
	1.30
+++ netwerk/protocol/http/src/nsHttpTransaction.h	18 Mar 2003 22:32:39 -000=
0
@@ -188,23 +188,24 @@
     PRLock                         *mLock;
=20
     // these transport status fields are protected by mLock
     nsresult                        mTransportStatus;
     PRUint32                        mTransportProgress;
     PRUint32                        mTransportProgressMax;
     PRPackedBool                    mTransportStatusInProgress;
=20
     PRUint16                        mRestartCount;        // the number of=
 times this transaction has been restarted
     PRUint8                         mCaps;
=20
     PRPackedBool                    mConnected;
     PRPackedBool                    mHaveStatusLine;
     PRPackedBool                    mHaveAllHeaders;
     PRPackedBool                    mTransactionDone;
     PRPackedBool                    mResponseIsComplete;  // =3D=3D mTrans=
actionDone && NS_SUCCEEDED(mStatus) ?
     PRPackedBool                    mDidContentStart;
     PRPackedBool                    mNoContent;           // expecting an =
empty entity body?
     PRPackedBool                    mReceivedData;
     PRPackedBool                    mDestroying;
+    PRPackedBool                    mClosed;
 };
=20
 #endif // nsHttpTransaction_h__

--=-u42aHKURhXQyBz+jIhGL--

--=-HEI6OgAM8ONhUq2GxjCV
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQA+nZSfb2iPiv4Uz4cRAtkHAJ9ebbI9Oiimd8KKgOquv+XQcaT2QACgodut
jZrgzqB2kNz5AJDvBlgHLWc=
=jOzf
-----END PGP SIGNATURE-----

--=-HEI6OgAM8ONhUq2GxjCV--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1050514591.606.46.camel>