From 2f2b59e28b6a7c0606a8b9ef8761ff12b07eafc7 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Wed, 30 Sep 2015 11:11:34 -0700 Subject: [PATCH] Backed out changeset 026a924b9228 (bug 1207850) for test_fetch_cors failures CLOSED TREE --- dom/fetch/Fetch.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp index 1a1c2dd28bb2..673002ab63ed 100644 --- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -1051,15 +1051,17 @@ public: uint8_t* nonconstResult = const_cast(aResult); if (mFetchBody->mWorkerPrivate) { + // This way if the runnable dispatch fails, the body is still released. + AutoFailConsumeBody autoFail(mFetchBody); nsRefPtr> r = new ContinueConsumeBodyRunnable(mFetchBody, aStatus, aResultLength, nonconstResult); AutoSafeJSContext cx; - if (!r->Dispatch(cx)) { - // XXXcatalinb: The worker is shutting down, the pump will be canceled - // by FetchBodyFeature::Notify. + if (r->Dispatch(cx)) { + autoFail.DontFail(); + } else { NS_WARNING("Could not dispatch ConsumeBodyRunnable"); // Return failure so that aResult is freed. return NS_ERROR_FAILURE; @@ -1129,12 +1131,10 @@ class FetchBodyFeature final : public workers::WorkerFeature // This is addrefed before the feature is created, and is released in ContinueConsumeBody() // so we can hold a rawptr. FetchBody* mBody; - bool mWasNotified; public: explicit FetchBodyFeature(FetchBody* aBody) : mBody(aBody) - , mWasNotified(false) { } ~FetchBodyFeature() @@ -1143,10 +1143,7 @@ public: bool Notify(JSContext* aCx, workers::Status aStatus) override { MOZ_ASSERT(aStatus > workers::Running); - if (!mWasNotified) { - mWasNotified = true; - mBody->ContinueConsumeBody(NS_BINDING_ABORTED, 0, nullptr); - } + mBody->ContinueConsumeBody(NS_BINDING_ABORTED, 0, nullptr); return true; } };