Closed Bug 2031881 Opened 6 months ago Closed 6 months ago

Consider adding nsIAsync{Input,Output}Stream implementations for OS pipes

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
152 Branch
Tracking Status
firefox151 --- fixed
firefox152 --- fixed

People

(Reporter: nika, Assigned: nika)

References

Details

Attachments

(2 external files, 1 obsolete file)

In our IPC code, we have an event loop for interacting with system level pipes/sockets in an async manner, but this is not really exposed to other consumers. This bug is to consider exposing this through XPCOM as a series of nsIAsync{Input,Output}Stream types.

The aim here is to make it easier for other components to take advantage of the async runtime we already use for our IPC backend.

Attachment #9570013 - Attachment description: WIP: Bug 2031881 - Add new AsyncPlatformPipes types → Bug 2031881 - Add new AsyncPlatformPipes types
Blocks: 2021345
Attachment #9570013 - Attachment description: Bug 2031881 - Add new AsyncPlatformPipes types → Bug 2031881 - Add new PlatformPipeReader type, r=jld!,#xpcom-reviewers!
Attachment #9570685 - Attachment is obsolete: true
Pushed by asilaghi@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a1d80969aac1 https://hg.mozilla.org/integration/autoland/rev/59dc69c853ad Revert "Bug 2031881 - Add new PlatformPipeReader type, r=jld" for causing build bustages at /AsyncPlatformPipes

Backed out for causing build bustages at /AsyncPlatformPipes
Backout Link
Push with failures
Failure Log
Failure line ../../../../checkouts/gecko/xpcom/io/AsyncPlatformPipes.cpp:X:23: error: logical 'or' of equal expressions [-Werror=logical-op]

Flags: needinfo?(nika)

This is a simple fix - I was missing an #if EWOULDBLOCK != EAGAIN check which is only necessary on old C++ compilers.

Flags: needinfo?(nika)
Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch
Regressions: 2035778

This is a new API which is intended to be used by code which wants to
perform async reads from native filesystem pipes. This does not support
async reads from "regular" files, as those are not compatible with
epoll.

Currently the API uses an owned buffer which is filled on the IPC I/O
thread, and read from on the user's thread. This is technically only
necessary for Windows (as non-Windows OSes could directly invoke read
during nsIInputStream::read method), This is because overlapped I/O on
Windows requires that the buffer be kept alive throughout the async
operation. So far I have made the call to always use the buffer for API
support consistency, but we could potentially change that behaviour.

The actual system file handle management is largely isolated to the
PlatformPipeLink type within the .cpp file. This is done to allow the
lifecycle of the nsIInputStream instance to be disconnected from the
lifecycle of the underlying pipe, as things like the buffer need to be
kept alive potentially longer than the stream to avoid issues on Windows
& handle cancelling I/O on destruction.

Currently there is no way to use this type with a shared file handle,
the file handle must be owned by the PlatformPipeLink.

Previous versions of this patch contained a PlatformPipeWriter type as
well, but that had some issues with lifecycle which I haven't yet
figured out yet, and turns out to not be necessary for the WebSerial
work right now, so are being left to a follow-up.

Original Revision: https://phabricator.services.mozilla.com/D294317

Attachment #9575261 - Flags: approval-mozilla-beta?
Attachment #9575261 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: