diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index 5bddbb6728bb..fa3b4b187baf 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -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; diff --git a/netwerk/base/nsSocketTransport2.h b/netwerk/base/nsSocketTransport2.h index b5a703aa0656..ba31e5c9199f 100644 --- a/netwerk/base/nsSocketTransport2.h +++ b/netwerk/base/nsSocketTransport2.h @@ -307,6 +307,9 @@ class nsSocketTransport final : public nsASocketHandler, Atomic mInputClosed{true}; Atomic mOutputClosed{true}; + nsCOMPtr mInputCopyContext; + nsCOMPtr mOutputCopyContext; + //------------------------------------------------------------------------- // members accessible only on the socket transport thread: // (the exception being initialization/shutdown time)