зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching between the source and sink streams, in order to enable or disable the WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a NS_AsyncCopy hanging until the source or sink are closed when is alternating between waiting on input and output streams. This patch relaxes the incorrect checks on various input streams. Differential Revision: https://phabricator.services.mozilla.com/D141034
This commit is contained in:
Родитель
d9c5936d5c
Коммит
a906eaf6b2
|
@ -422,7 +422,8 @@ RemoteLazyInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
|
||||
// We are still waiting for the remote inputStream
|
||||
case ePending: {
|
||||
if (mInputStreamCallback && aCallback) {
|
||||
if (NS_WARN_IF(mInputStreamCallback && aCallback &&
|
||||
mInputStreamCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -434,7 +435,8 @@ RemoteLazyInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
// We have the remote inputStream, let's check if we can execute the
|
||||
// callback.
|
||||
case eRunning: {
|
||||
if (mInputStreamCallback && aCallback) {
|
||||
if (NS_WARN_IF(mInputStreamCallback && aCallback &&
|
||||
mInputStreamCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -454,7 +456,8 @@ RemoteLazyInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
[[fallthrough]];
|
||||
default:
|
||||
MOZ_ASSERT(mState == eClosed);
|
||||
if (mInputStreamCallback && aCallback) {
|
||||
if (NS_WARN_IF(mInputStreamCallback && aCallback &&
|
||||
mInputStreamCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -140,7 +140,8 @@ NS_IMETHODIMP BlobURLInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
}
|
||||
|
||||
// Pre-empting a valid callback with another is not allowed.
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback)) {
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
|
||||
mAsyncWaitCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,8 @@ PartiallySeekableInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
if (mAsyncWaitCallback && aCallback) {
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
|
||||
mAsyncWaitCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -676,7 +676,8 @@ nsBufferedInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (mAsyncWaitCallback && aCallback) {
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
|
||||
mAsyncWaitCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,8 @@ nsMIMEInputStream::AsyncWait(nsIInputStreamCallback* aCallback, uint32_t aFlags,
|
|||
nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
if (mAsyncWaitCallback && aCallback) {
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
|
||||
mAsyncWaitCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -207,7 +207,8 @@ nsInputStreamTransport::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (mAsyncWaitCallback && aCallback) {
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
|
||||
mAsyncWaitCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -205,26 +205,16 @@ InputStreamLengthWrapper::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
NS_ENSURE_STATE(mInputStream);
|
||||
NS_ENSURE_STATE(mWeakAsyncInputStream);
|
||||
|
||||
nsCOMPtr<nsIInputStreamCallback> callback = this;
|
||||
nsCOMPtr<nsIInputStreamCallback> callback = aCallback ? this : nullptr;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (mAsyncWaitCallback && aCallback) {
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
|
||||
mAsyncWaitCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
bool hadCallback = !!mAsyncWaitCallback;
|
||||
mAsyncWaitCallback = aCallback;
|
||||
|
||||
if (!mAsyncWaitCallback) {
|
||||
if (!hadCallback) {
|
||||
// No pending operation.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Abort current operation.
|
||||
callback = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return mWeakAsyncInputStream->AsyncWait(callback, aFlags, aRequestedCount,
|
||||
|
|
|
@ -307,7 +307,8 @@ SlicedInputStream::AsyncWait(nsIInputStreamCallback* aCallback, uint32_t aFlags,
|
|||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (mAsyncWaitCallback && aCallback) {
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
|
||||
mAsyncWaitCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -820,7 +820,8 @@ nsMultiplexInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
|||
return mStatus;
|
||||
}
|
||||
|
||||
if (mAsyncWaitCallback && aCallback) {
|
||||
if (NS_WARN_IF(mAsyncWaitCallback && aCallback &&
|
||||
mAsyncWaitCallback != aCallback)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче