Bug 764758 - Intermittent crash during test_xhtmlManifest.xhtml [@ nsOfflineCacheUpdateItem::OnDataAvailable], part2, r=jduell
authorHonza Bambas <honzab.moz@firemni.cz>
Mon, 22 Oct 2012 19:59:07 +0200
changeset 111193 14516fa301a34db4b12e89d9fbaed64b533ed586
parent 111192 7e6fcfed1b74ba527dffb1f268e446dc7a28612c
child 111194 d7b878ec3d7d34c02d6cdb50e9efb57df856b765
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjduell
bugs764758
milestone19.0a1
Bug 764758 - Intermittent crash during test_xhtmlManifest.xhtml [@ nsOfflineCacheUpdateItem::OnDataAvailable], part2, r=jduell
uriloader/prefetch/nsOfflineCacheUpdate.cpp
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
@@ -312,16 +312,24 @@ nsOfflineCacheUpdateItem::OpenChannel(ns
 #if defined(PR_LOGGING)
     if (LOG_ENABLED()) {
         nsAutoCString spec;
         mURI->GetSpec(spec);
         LOG(("%p: Opening channel for %s", this, spec.get()));
     }
 #endif
 
+    if (mUpdate) {
+        // Holding a reference to the update means this item is already
+        // in progress (has a channel, or is just in between OnStopRequest()
+        // and its Run() call.  We must never open channel on this item again.
+        LOG(("  %p is already running! ignoring", this));
+        return NS_ERROR_ALREADY_OPENED;
+    }
+
     nsresult rv = nsOfflineCacheUpdate::GetCacheKey(mURI, mCacheKey);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = NS_NewChannel(getter_AddRefs(mChannel),
                        mURI,
                        nullptr, nullptr, this,
                        nsIRequest::LOAD_BACKGROUND |
                        nsICachingChannel::LOAD_ONLY_IF_MODIFIED |