Closed hannesm closed 8 months ago
The idea is (considering that the client only deals with a single channel!)
shutdown `write
is a half-close, sending EOF to the other side (any subsequent write
returns `closed
) (reads can still occur and return data)close
(or shutdown `read_write
) is a full-close, sending CLOSE to the other side and closing the underlying flow (subsequent read return `eof
, write `closed
)shutdown `read
should empty the receive buffer, and subsequent reads return `eof
(writes can still occur and send data)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.
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.
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.
This provides proper
close
andshutdown
functionality.