mirage / awa-ssh

Purely functional SSH library in ocaml.
ISC License
104 stars 12 forks source link

Adapt to mirage-flow 4 API #70

Closed hannesm closed 8 months ago

hannesm commented 9 months ago

This provides proper close and shutdown functionality.

hannesm commented 9 months ago

The idea is (considering that the client only deals with a single channel!)

hannesm commented 9 months ago

now, this is really ready from my point of view. certainly there's still room for improvement (e.g. from the RFC - when a channel_close is received, it should be answered with a channel_close -- didn't check for that). but the basic (client) API is fine in respect to close/shutdown/half-close.

hannesm commented 8 months ago

I added a minor thing yesterday.

I would move ahead and merge this. The main takeaway is: mirage-flow 4 supports a shutdown - now we can be in half-closed sessions - and then continue to read or write data over the channel. (This is all ssh-client only, since the ssh-server doesn't deal with flows.)

For the layering, if the ssh flow ends up in closed state, we'll call underlying.close to clean up the resources. I think this is good behaviour.

If someone has further ideas/hints on this PR (or does another review), please indicate. Otherwise, I plan to merge and release really soon now.

hannesm commented 8 months ago

And one minor nit is to F.close in shutdown if the internal state is `Closed or `Error. The reasoning is that an application calling shutdown should not leak any descriptors.