swift-nio icon indicating copy to clipboard operation
swift-nio copied to clipboard

NIOPosix: remove use of `setNonBlockingIO` on Windows pipes

Open compnerd opened this issue 2 years ago • 5 comments

On Windows anonymous pipes are not easy to make non-blocking. Furthermore, doing so in any reasonably useful manner requires using undocumented tricks which makes it vaguely but not entirely similar to Unix semantics. Prevent this operation on Windows for the time being.

compnerd avatar Jun 15 '22 17:06 compnerd

Well, pipes are fine, it just is that anonymous pipes don't have a way to be marked as async, though all IO on Windows is technically async (you can use IO Completion Ports, or overlapped IO).

https://docs.microsoft.com/en-us/windows/win32/ipc/named-pipe-type-read-and-wait-modes

compnerd avatar Jun 16 '22 16:06 compnerd

Yes, I'm familiar with IOCP. The problem here is that NIOPOSIX will not be using IOCP (it's intended to be the POSIX compat layer), so futzing with this in order to get it to work that way is less than ideal. If the POSIX APIs on Windows don't support non-blocking operation of anonymous pipes then we should forbid using them on that platform.

Lukasa avatar Jun 17 '22 06:06 Lukasa

The one thing that I am concerned about is surfacing the API differences ... that has always caused trouble as it ends up causing downstream packages to break when they chance as there isn't always sufficient testing to ensure that all the paths are updated properly.

compnerd avatar Jun 17 '22 15:06 compnerd

What surfacing of the different API surfaces do you mean?

Lukasa avatar Jun 17 '22 15:06 Lukasa

If there are public interfaces that may reference anything. I suppose the alternate way to approach this: what exactly do you have in mind to remove?

compnerd avatar Jun 17 '22 16:06 compnerd