Closed Bug 1818305 Opened 1 year ago Closed 1 year ago

Back-propagate errors faster from output to input streams in NS_AsyncCopy

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: nika, Assigned: nika)

References

Details

Attachments

(3 files)

Currently errors on the output stream side of NS_AsyncCopy are only detected and propagated to the input stream side when the input stream has data available to write. Until then, there will be a tight loop as the output stream repeatedly tries to notify the nsAStreamCopier that it has been closed, and the copier has no data to copy & write.

We should support detecting an error when there is no data available more eagerly so that the stream can be closed as soon as the output stream knows that it is closed.

This new method can be used to check if the nsIOutputStream has been
closed without having data available to write. It should avoid blocking
to discover this information.

This is semantically similar to the existing available() method, however will
not block, and doesn't need to do the work to actually determine the number of
available bytes.

As part of this patch, I also fixed one available() implementation which was
incorrectly throwing NS_BASE_STREAM_WOULD_BLOCK.

Depends on D170696

This will ensure that errors in one side of a NS_AsyncCopy will more reliably
propagate to the other side of the NS_AsyncCopy, by allowing us to check for
situations like stream closure reliably even when the other side either has no
available data, or no available space.

Depends on D170697

Pushed by nlayzell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ad7ac4f91b9a
Part 1: Add a streamStatus method to nsIOutputStream, r=necko-reviewers,geckoview-reviewers,jesup,emilio,m_kato,devtools-reviewers
https://hg.mozilla.org/integration/autoland/rev/015237a08f40
Part 2: Add a streamStatus method to nsIInputStream, r=xpcom-reviewers,necko-reviewers,geckoview-reviewers,valentin,jesup,m_kato,mccr8
https://hg.mozilla.org/integration/autoland/rev/a2443ec9d2d4
Part 3: Check streamStatus from nsAStreamCopier, r=xpcom-reviewers,mccr8
https://hg.mozilla.org/integration/autoland/rev/fdcfe06fa13e
apply code formatting via Lando
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: