Bug 458206 - Abort @ ~nsXMLHttpRequest, r+sr=sicking
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Wed, 08 Oct 2008 14:08:01 +0300
changeset 20133 5360fea9b06b1250bb1fa48bcd642a4ea89b7049
parent 20132 b222f6e972b32fa72b9fc8bff32279de0bcc68dc
child 20134 3a3f885ce36da6030bc9c95cfa56bd8fe4da45ce
push idunknown
push userunknown
push dateunknown
bugs458206
milestone1.9.1b2pre
Bug 458206 - Abort @ ~nsXMLHttpRequest, r+sr=sicking
content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -2573,20 +2573,16 @@ nsXMLHttpRequest::Send(nsIVariant *aBody
   }
 
   // Reset responseBody
   mResponseBody.Truncate();
 
   // Reset responseXML
   mDocument = nsnull;
 
-  if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
-    mState |= XML_HTTP_REQUEST_SYNCLOOPING;
-  }
-
   rv = CheckChannelForCrossSiteRequest(mChannel);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRBool withCredentials = !!(mState & XML_HTTP_REQUEST_AC_WITH_CREDENTIALS);
 
   if (mState & XML_HTTP_REQUEST_USE_XSITE_AC) {
     // Check if we need to do a preflight request.
     NS_ENSURE_TRUE(httpChannel, NS_ERROR_DOM_BAD_URI);
@@ -2681,17 +2677,17 @@ nsXMLHttpRequest::Send(nsIVariant *aBody
   //    responses, so they are not worth caching.
   if ((mState & XML_HTTP_REQUEST_MULTIPART) || method.EqualsLiteral("POST")) {
     AddLoadFlags(mChannel,
         nsIRequest::LOAD_BYPASS_CACHE | nsIRequest::INHIBIT_CACHING);
   }
   // When we are sync loading, we need to bypass the local cache when it would
   // otherwise block us waiting for exclusive access to the cache.  If we don't
   // do this, then we could dead lock in some cases (see bug 309424).
-  else if (mState & XML_HTTP_REQUEST_SYNCLOOPING) {
+  else if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
     AddLoadFlags(mChannel,
         nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY);
     if (mACGetChannel) {
       AddLoadFlags(mACGetChannel,
           nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY);
     }
   }
 
@@ -2732,16 +2728,17 @@ nsXMLHttpRequest::Send(nsIVariant *aBody
   // Now that we've successfully opened the channel, we can change state.  Note
   // that this needs to come after the AsyncOpen() and rv check, because this
   // can run script that would try to restart this request, and that could end
   // up doing our AsyncOpen on a null channel if the reentered AsyncOpen fails.
   ChangeState(XML_HTTP_REQUEST_SENT);
 
   // If we're synchronous, spin an event loop here and wait
   if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
+    mState |= XML_HTTP_REQUEST_SYNCLOOPING;
     nsIThread *thread = NS_GetCurrentThread();
     while (mState & XML_HTTP_REQUEST_SYNCLOOPING) {
       if (!NS_ProcessNextEvent(thread)) {
         rv = NS_ERROR_UNEXPECTED;
         break;
       }
     }
   } else {