spebern/async-ssh2

waking up concurrent reads on the same session

Opened this issue · 1 comments

wez commented

I don't know for sure if this is a problem in reality, but in thinking about this problem space in wezterm, I think it might be.

In wezterm we create a session to talk to the remote host with a channel at initial connection. Then the user can spawn additional tabs, each one is a separate channel with its own pty, but all multiplexed on the same session.

The situation I'm unsure of is if we have 2 or more channels on the same session that are waiting for read. When the underlying fd becomes ready, does the tokio plumbing cause both read futures to be polled, or only one of them? If the latter then I think we'll need some additional logic to fan out the wakeup.

I think that needs some additional work:

Note: While PollEvented is Sync (if the underlying I/O type is Sync), the caller must ensure that there are at most two tasks that use a PollEvented instance concurrently. One for reading and one for writing. While violating this requirement is "safe" from a Rust memory model point of view, it will result in unexpected behavior in the form of lost notifications and tasks hanging.

https://docs.rs/tokio/0.2.11/tokio/io/struct.PollEvented.html

I just opened tokio-rs/tokio#2200, so the plumbing I use right now might also change.