Bug 1517071 - Clear AsyncWaitRunnable::mStream when cancelled. r=froydnj

AsyncWaitRunnable holds a strong reference to its stream, and
NonBlockingAsyncInputStream holds a strong reference to the
runnable. The cycle gets broken in the RunAsyncWaitCallback() method
of the stream, but if the runnable is cancelled then we leak them
both. This patch fixes that by clearing the pointer to the stream when
the runnable is cancelled, breaking the cycle.

Differential Revision: https://phabricator.services.mozilla.com/D16248

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2019-01-11 14:36:45 +00:00
Родитель 642dd2cc11
Коммит d98ef96a18
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -1,2 +0,0 @@
lsan-allowed: [Alloc, AllocateProtoAndIfaceCache, EntrySlotOrCreate, MakeNotNull, MakeUnique, Malloc, NS_NewCStringInputStream, NewEmptyScopeData, NewPage, ProtoAndIfaceCache, js_new, js_pod_calloc, js_pod_malloc, js_pod_realloc, mozilla::BackgroundHangThread::ReportHang, mozilla::NonBlockingAsyncInputStream::AsyncWait, mozilla::NonBlockingAsyncInputStream::Create, mozilla::dom::Blob::Constructor, mozilla::dom::Blob::Create, mozilla::dom::FileReader::Constructor, mozilla::dom::StringBlobImpl::Create, mozilla::dom::WorkerPrivate::GetOrCreateGlobalScope, mozilla::dom::WorkerPrivate::WorkerPrivate, mozilla::dom::WorkerThread::Create, nsThread::nsThread]
leak-threshold: [default:51200]

Просмотреть файл

@ -29,6 +29,12 @@ class NonBlockingAsyncInputStream::AsyncWaitRunnable final
mStream->RunAsyncWaitCallback(this, mCallback.forget());
return NS_OK;
}
NS_IMETHOD
Cancel() override {
mStream = nullptr;
return NS_OK;
}
};
NS_IMPL_ADDREF(NonBlockingAsyncInputStream);