Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This related to my comment on #109 (comment).
I managed to find the real problem.

In russh/src/client/encrypted.rs:
When received channel close message, it removes the channel first from channel map, then send back channel_close message to server by
Encrypted::byte
function.But in
Encrypted::byte
function, it checks the channel map to actually send the message, since it has been removed, the close message never got send to the server, this keeps the server channel leak.My solution is to move remove channel in map code into
Encrypted::close
function.If client initiate close,
Encrypted::close
will be invoked, close message will be sent to server and removed in local channel map, if later received server close message, as channel has been removed, no close message will be send again.If server initiate close,
Encrypted::close
will be invoked too, close message will be sent to server and removed in local channel map.