Skip to content
Snippets Groups Projects
Commit a2bdc46c authored by Nika Layzell's avatar Nika Layzell
Browse files

Bug 1782181 - Part 2: Notify nsMultiplexInputStream callbacks if AsyncWait fails, r=asuth, a=dsmith

When `nsMultiplexInputStream` calls `AsyncWait` from within
`OnInputStreamReady`, it is possible for those calls to fail. In that case, we
will fail to notify AsyncWait listeners, which could lead to leaks or stream
hangs. This patch changes the error handling in this situation to instead fire
a pending stream callback after an error when re-dispatching `AsyncWait`.

Depends on D153628

Differential Revision: https://phabricator.services.mozilla.com/D153629
parent 8787b4b6
No related branches found
No related tags found
No related merge requests found
......@@ -926,8 +926,13 @@ nsMultiplexInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) {
if (NS_FAILED(rv)) {
NextStream();
}
// Unlock and invoke AsyncWaitInternal to wait again. If this succeeds,
// we'll be called again, otherwise fall through and notify.
MutexAutoUnlock unlock(mLock);
return AsyncWaitInternal();
if (NS_SUCCEEDED(AsyncWaitInternal())) {
return NS_OK;
}
}
}
......@@ -935,7 +940,7 @@ nsMultiplexInputStream::OnInputStreamReady(nsIAsyncInputStream* aStream) {
mAsyncWaitEventTarget = nullptr;
}
return callback->OnInputStreamReady(this);
return callback ? callback->OnInputStreamReady(this) : NS_OK;
}
void nsMultiplexInputStream::AsyncWaitCompleted() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment