Bug 467392 - Docshell leak with document.write(document.body.innerHTML) and window.location.reload r=michal.novotny, a=blocking-final+
authorbjarne@runitsoft.com
Fri, 21 Jan 2011 15:13:26 -0500
changeset 61109 c3917d4b7a65475f5fb34ec7f80244d37b2aed59
parent 61108 c249c39e6f21c5ea1ea72a50c901e694887145dd
child 61110 7699976cd9defa01295252999f9af0a96ea75cca
push idunknown
push userunknown
push dateunknown
reviewersmichal, blocking-final
bugs467392
milestone2.0b10pre
Bug 467392 - Docshell leak with document.write(document.body.innerHTML) and window.location.reload r=michal.novotny, a=blocking-final+
netwerk/cache/nsCacheService.cpp
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -2372,16 +2372,17 @@ nsCacheService::ProcessPendingRequests(n
         }
         
         if (request == &entry->mRequestQ)   // no requests asked for ACCESS_READ_WRITE, back to top
             request = (nsCacheRequest *)PR_LIST_HEAD(&entry->mRequestQ);
         
         // XXX what should we do if there are only READ requests in queue?
         // XXX serialize their accesses, give them only read access, but force them to check validate flag?
         // XXX or do readers simply presume the entry is valid
+        // See fix for bug #467392 below
     }
 
     nsCacheAccessMode  accessGranted = nsICache::ACCESS_NONE;
 
     while (request != &entry->mRequestQ) {
         nextRequest = (nsCacheRequest *)PR_NEXT_LINK(request);
         CACHE_LOG_DEBUG(("  %sync request %p for %p\n",
                         (request->mListener?"As":"S"), request, entry));
@@ -2416,17 +2417,25 @@ nsCacheService::ProcessPendingRequests(n
                 // post call to listener to report error or descriptor
                 rv = NotifyListener(request, descriptor, accessGranted, rv);
                 delete request;
                 if (NS_FAILED(rv)) {
                     // XXX what to do?
                 }
                 
             } else {
-                // XXX bad state
+                // read-only request to an invalid entry - need to wait for
+                // the entry to become valid so we post an event to process
+                // the request again later (bug #467392)
+                nsCOMPtr<nsIRunnable> ev =
+                    new nsProcessRequestEvent(request);
+                rv = DispatchToCacheIOThread(ev);
+                if (NS_FAILED(rv)) {
+                    delete request; // avoid leak
+                }
             }
         } else {
 
             // Synchronous request
             request->WakeUp();
         }
         if (newWriter)  break;  // process remaining requests after validation
         request = nextRequest;