Bug 743178, CORS may keep XHR alive too long, r=bz, a=tracking-firefox14+
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 17 Apr 2012 23:55:40 +0300
changeset 95152 719a2fb28324ec55ab92c776c31c5ef4517ed91e
parent 95151 3a9629092a5f6f17f83913de422fd41a5c9f71d7
child 95197 93dfd98900ad8e01e64e0bafb8880209777c5811
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, tracking-firefox14
bugs743178
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 743178, CORS may keep XHR alive too long, r=bz, a=tracking-firefox14+
content/base/src/nsCrossSiteListenerProxy.cpp
content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/src/nsCrossSiteListenerProxy.cpp
+++ b/content/base/src/nsCrossSiteListenerProxy.cpp
@@ -634,17 +634,23 @@ nsCORSListenerProxy::CheckRequestApprove
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCORSListenerProxy::OnStopRequest(nsIRequest* aRequest,
                                    nsISupports* aContext,
                                    nsresult aStatusCode)
 {
-  return mOuterListener->OnStopRequest(aRequest, aContext, aStatusCode);
+  nsresult rv = mOuterListener->OnStopRequest(aRequest, aContext, aStatusCode);
+  mOuterListener = nsnull;
+  mOuterNotificationCallbacks = nsnull;
+  mRedirectCallback = nsnull;
+  mOldRedirectChannel = nsnull;
+  mNewRedirectChannel = nsnull;
+  return rv;
 }
 
 NS_IMETHODIMP
 nsCORSListenerProxy::OnDataAvailable(nsIRequest* aRequest,
                                      nsISupports* aContext, 
                                      nsIInputStream* aInputStream,
                                      PRUint32 aOffset,
                                      PRUint32 aCount)
@@ -1021,16 +1027,19 @@ nsCORSPreflightListener::OnStartRequest(
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCORSPreflightListener::OnStopRequest(nsIRequest *aRequest,
                                        nsISupports *aContext,
                                        nsresult aStatus)
 {
+  mOuterChannel = nsnull;
+  mOuterListener = nsnull;
+  mOuterContext = nsnull;
   return NS_OK;
 }
 
 /** nsIStreamListener methods **/
 
 NS_IMETHODIMP
 nsCORSPreflightListener::OnDataAvailable(nsIRequest *aRequest,
                                          nsISupports *ctxt,
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -2497,16 +2497,17 @@ nsXMLHttpRequest::ChangeStateToDone()
   }
 
   if (mErrorLoad) {
     // By nulling out channel here we make it so that Send() can test
     // for that and throw. Also calling the various status
     // methods/members will not throw.
     // This matches what IE does.
     mChannel = nsnull;
+    mCORSPreflightChannel = nsnull;
   }
   else if (!(mState & XML_HTTP_REQUEST_GOT_FINAL_STOP)) {
     // We're a multipart request, so we're not done. Reset to opened.
     ChangeState(XML_HTTP_REQUEST_OPENED);
   }
 }
 
 NS_IMETHODIMP