dotnet / dotnet/runtime

Make AnonymousPipeStreams support async IO on Windows

Open
#125,451 2 comments 0 reactions 0 assignees View on GitHub
area-System.IO
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

With https://github.com/dotnet/runtime/issues/122806 it's going to be possible to create anonymous pipes with `FILE_FLAG_OVERLAPPED` on Windows (because they are just named pipes on Windows).

We should consider making `AnonymousPipeServerStream` and `AnonymousPipeClientStream` support async IO on Windows as well.

Ideally, we should implement https://github.com/dotnet/runtime/issues/58381 first, and then remove all the code duplication from `System.IO.Pipes` and just delegate all the work (on Windows) to `RandomAccess`.

With https://github.com/dotnet/runtime/pull/125220 (which adds `O_NONBLOCK` support to `RandomAccess` on Unix) some of the issues are no longer blocking (https://github.com/dotnet/runtime/pull/96711#discussion_r1464050855). But https://github.com/dotnet/runtime/issues/47631 is what would provide the optimal implementation.

If we are going to reduce the code duplication for named pipes as well, we are definitely going to hit https://github.com/dotnet/runtime/issues/28585.

I believe the following order should work:
- https://github.com/dotnet/runtime/pull/125220 needs to get merged first
- implement https://github.com/dotnet/runtime/issues/58381, use https://github.com/dotnet/runtime/pull/96711 as inspiration (one PR, doable by Agent)
- make AnonymousPipeStreams support async IO on Windows by delegating all the work to `RandomAccess` (one PR, doable by Agent)
- find a proper solution for https://github.com/dotnet/runtime/issues/28585 (one PR, will most likely require human design work, but I can be wrong). It may require a new public type (for example, a common base type for `SafeFileHandle` and `SafePipeHandle`)
- remove code duplication for named pipes on Windows (one PR, doable by Agent)
- when https://github.com/dotnet/runtime/issues/47631 is implemented, make `RandomAccess.*Async` methods use it for `O_NONBLOCK` handles and make AnonymousPipeStreams delegating all the work to `RandomAccess` on Unix as well (one PR, doable by Agent)

cc @stephentoub

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.