Bug 1835430 - Cancel async copy to avoid leaks, r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D181643
This commit is contained in:
Kershaw Chang 2023-06-21 19:18:42 +00:00
Родитель 47a79d59b0
Коммит d325869b9a
2 изменённых файлов: 13 добавлений и 2 удалений

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

@ -2243,6 +2243,12 @@ void nsSocketTransport::OnSocketDetached(PRFileDesc* fd) {
//
mInput.OnSocketReady(mCondition);
mOutput.OnSocketReady(mCondition);
if (mInputCopyContext) {
NS_CancelAsyncCopy(mInputCopyContext, mCondition);
}
if (mOutputCopyContext) {
NS_CancelAsyncCopy(mOutputCopyContext, mCondition);
}
}
if (mCondition == NS_ERROR_NET_RESET && mDNSRecord &&
@ -2334,7 +2340,8 @@ nsSocketTransport::OpenInputStream(uint32_t flags, uint32_t segsize,
// async copy from socket to pipe
rv = NS_AsyncCopy(&mInput, pipeOut, mSocketTransportService,
NS_ASYNCCOPY_VIA_WRITESEGMENTS, segsize);
NS_ASYNCCOPY_VIA_WRITESEGMENTS, segsize, nullptr, nullptr,
true, true, getter_AddRefs(mInputCopyContext));
if (NS_FAILED(rv)) return rv;
result = pipeIn;
@ -2380,7 +2387,8 @@ nsSocketTransport::OpenOutputStream(uint32_t flags, uint32_t segsize,
// async copy from socket to pipe
rv = NS_AsyncCopy(pipeIn, &mOutput, mSocketTransportService,
NS_ASYNCCOPY_VIA_READSEGMENTS, segsize);
NS_ASYNCCOPY_VIA_READSEGMENTS, segsize, nullptr, nullptr,
true, true, getter_AddRefs(mOutputCopyContext));
if (NS_FAILED(rv)) return rv;
result = pipeOut;

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

@ -307,6 +307,9 @@ class nsSocketTransport final : public nsASocketHandler,
Atomic<bool> mInputClosed{true};
Atomic<bool> mOutputClosed{true};
nsCOMPtr<nsISupports> mInputCopyContext;
nsCOMPtr<nsISupports> mOutputCopyContext;
//-------------------------------------------------------------------------
// members accessible only on the socket transport thread:
// (the exception being initialization/shutdown time)