зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1782181 - Part 1: Support canceling AsyncWait in nsMultiplexInputStream, r=asuth
Previously nsMultiplexInputStream would not call `AsyncWait` again when the callback was cleared, meaning that the underlying wait wouldn't actually be cancelled. This patch changes the behaviour to more consistently forward the cancelling call to the underlying stream. There are still some cases where the call will not be cancelled if a read or other event caused the stream cursor to advance before canceling, however those should generally be uncommon. Differential Revision: https://phabricator.services.mozilla.com/D153628
This commit is contained in:
Родитель
d7f0b286fe
Коммит
b7b9c6816e
|
@ -827,10 +827,6 @@ nsMultiplexInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
mAsyncWaitFlags = aFlags;
|
||||
mAsyncWaitRequestedCount = aRequestedCount;
|
||||
mAsyncWaitEventTarget = aEventTarget;
|
||||
|
||||
if (!mAsyncWaitCallback) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return AsyncWaitInternal();
|
||||
|
@ -838,6 +834,7 @@ nsMultiplexInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
|
||||
nsresult nsMultiplexInputStream::AsyncWaitInternal() {
|
||||
nsCOMPtr<nsIAsyncInputStream> stream;
|
||||
nsIInputStreamCallback* asyncWaitCallback = nullptr;
|
||||
uint32_t asyncWaitFlags = 0;
|
||||
uint32_t asyncWaitRequestedCount = 0;
|
||||
nsCOMPtr<nsIEventTarget> asyncWaitEventTarget;
|
||||
|
@ -869,6 +866,7 @@ nsresult nsMultiplexInputStream::AsyncWaitInternal() {
|
|||
}
|
||||
}
|
||||
|
||||
asyncWaitCallback = mAsyncWaitCallback ? this : nullptr;
|
||||
asyncWaitFlags = mAsyncWaitFlags;
|
||||
asyncWaitRequestedCount = mAsyncWaitRequestedCount;
|
||||
asyncWaitEventTarget = mAsyncWaitEventTarget;
|
||||
|
@ -879,12 +877,14 @@ nsresult nsMultiplexInputStream::AsyncWaitInternal() {
|
|||
// If we are here it's because we are already closed, or if the current stream
|
||||
// is not async. In both case we have to execute the callback.
|
||||
if (!stream) {
|
||||
AsyncWaitRunnable::Create(this, asyncWaitEventTarget);
|
||||
if (asyncWaitCallback) {
|
||||
AsyncWaitRunnable::Create(this, asyncWaitEventTarget);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return stream->AsyncWait(this, asyncWaitFlags, asyncWaitRequestedCount,
|
||||
asyncWaitEventTarget);
|
||||
return stream->AsyncWait(asyncWaitCallback, asyncWaitFlags,
|
||||
asyncWaitRequestedCount, asyncWaitEventTarget);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
Загрузка…
Ссылка в новой задаче