Bug 662555 - Race condition when measuring responseEnd; r=jduell.mcbugs
authorHonza Bambas <honzab.moz@firemni.cz>
Sun, 21 Aug 2011 09:27:29 +0100
changeset 75616 95996d0763a6b739ac9db4e472aa031ce7961f40
parent 75615 13010f8b9fe1d2920b5d77d305ae66983cd053d8
child 75617 c3679628bee56a99d714920dd17359bfa747190a
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjduell
bugs662555
milestone9.0a1
Bug 662555 - Race condition when measuring responseEnd; r=jduell.mcbugs
netwerk/protocol/http/nsHttpTransaction.cpp
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -587,18 +587,16 @@ nsHttpTransaction::Close(nsresult reason
 
     NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     if (mClosed) {
         LOG(("  already closed\n"));
         return;
     }
 
-    mTimings.responseEnd = mozilla::TimeStamp::Now();
-
     if (mActivityDistributor) {
         // report the reponse is complete if not already reported
         if (!mResponseIsComplete)
             mActivityDistributor->ObserveActivity(
                 mChannel,
                 NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
                 NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
                 PR_Now(),
@@ -1116,16 +1114,19 @@ nsHttpTransaction::HandleContent(char *b
 
     // check for end-of-file
     if ((mContentRead == mContentLength) ||
         (mChunkedDecoder && mChunkedDecoder->ReachedEOF())) {
         // the transaction is done with a complete response.
         mTransactionDone = PR_TRUE;
         mResponseIsComplete = PR_TRUE;
 
+        if (TimingEnabled())
+            mTimings.responseEnd = mozilla::TimeStamp::Now();
+
         // report the entire response has arrived
         if (mActivityDistributor)
             mActivityDistributor->ObserveActivity(
                 mChannel,
                 NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
                 NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
                 PR_Now(),
                 static_cast<PRUint64>(mContentRead),