-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design of named pipes support on windows #3511
Comments
Well. My only use case is to be able to connect to MySql on Windows. Named pipes show significantly better performance over TCP.
This feature was mentioned as a must-have by @faern here. As far as I can see it'll have no impact on API design. We could simply add it in a form similar to this one. I found no safe rust wrappers for
I have nothing to say about use cases.
It's a powerful feature that is assumed to allow a priveleged server to temporarily lower its privileges down to a client's but may be used in other direction which is quite dangerous especially in the context of Named Pipe Instance Creation Race Condition. Please read this small document for more info.
I believe this could be exposed as a function that returns a bunch of servers, as mentioned by @simonbuchan. The upper bound is 254.
Seems like anonymous pipes and named pipes are unrelated to each other and anonymous pipes are out of scope.
I have nothing to say about use cases. Anyway, it should not affect the API design.
I've used this implementation as a source of inspiration for #3388, but not from the design perspective. The design mimics UnixListener/UnixStream API. The good rust implementation I can think of is the one from miow.
Even though #3388 mostly mimics UnixStream/UnixListener, I have to admit that the API is somewhat incompatible with named pipes. The problem lays in the fact, that there is no way to bind to a pipe name without creating an instance. I see two options to solve this:
I believe that it's possible to come up with an ad-hoc solution to this, but I'd rather choose to avoid it from the API design side, if possible. |
I'm not sure I understand If that is a nightmare for some reason, I'm pretty mixed. Cloning The point on safely implementing
There's the (optional!) OS-enforced limit in I find the comment
interesting: to my understanding |
When used as the Windows equivalent of UDS (normally for local IPC) there are at least two things to think about with regards to access permissions:
I think whatever API tokio exposes has to allow setting these two things on pipe creation. Maybe not in a super nice way, maybe not safely, but it must be possible. Otherwise the API becomes somewhat useless from an IPC standpoint.
Yes. At least for our use case. The only thing I have ever used named pipes for is for the equivalent of IPC via UDS on Windows. |
I've always been a bit confused about the difference between named pipes, and the named shared memory protocol. I'm mostly staying on the Linux side to have a deep knowledge about Microsoft's protocols, but I'd like to know are these two protocols the same? SQL Server allows you to explicitly enable the named pipe protocol, and by default only allows the shared memory protocol. Could we use the |
@pimeys Roughly, named pipes is UDS, named shared memory is unix shared memory - literally sharing a raw hunk of memory between multiple processes, bring your own synchronization. |
I've put together a preliminary working prototype in #3760 based on the proposal in #3388. See the PR for motivation and design. |
We would be happy to hear feedback on #3760. If you have time to look at it, please post your thoughts. |
Closing as #3760 was merged. |
@Darksonn although #3760 is merged and I don't have all the insight into the inner workings of named pipes, what @blackbeam spoke about. However helpers akin to UnixListener/UnixStream for named pipes would still make sense in terms of ergonomics. Right now it's very simple to get started with UDS, easy to wrap it with tokio-stream and then toss it towards tonic server or anything else. Very different story with named pipes and practically no available solutions, I am only aware of mostly abandoned parity-tokio-ipc crate, but I think windows folks would greatly benefit from having equally great support for pipes in tokio. |
The current API matches what the OS provides, so we need to use that API to allow full flexibility for users. And we generally, do not have any other case where Tokio provides two versions of the same API, with one being a wrapper of the other that is more convenient. So my gut feeling is that this belongs in its own crate. If you want to discuss this further, then open a new issue. |
We've had our own wrapping API over tokio UDS and Named Pipes since before tokio added this; it's not too hard to get running (probably ~50-100 lines from years old memory...), but it's tricky to completely paper over the path and locking semantics, so I'd say it's probably not a great idea to try to hide those differences. Specifically, we wanted exactly one server to be the "canonical" one using whichever process can serve on the socket but it's pretty ugly to get that to be reliable on Unix. (There's probably a much nicer application level approach) |
@Darksonn ok agree. @simonbuchan I took time and figured out how to implement the wrapper myself. My primary issue was making my own stream which ultimately I solved with |
The purpose of this issue is to flesh out a good API for supporting named pipes on windows. To help out with this effort, here are some good starting points for discussion:
UnixStream
/UnixListener
?AsyncFd
? If so, how would it differ fromAsyncFd
? Or does the raw named pipes API look totally different?UnixStream
/UnixListener
mirror and a more raw API?UnixDatagram
?The text was updated successfully, but these errors were encountered: