Fix #805: Prevent CHANNEL_CLOSE to be sent between Channel.isOpen and…#813
Merged
hierynomus merged 2 commits intohierynomus:masterfrom Sep 17, 2022
Merged
Fix #805: Prevent CHANNEL_CLOSE to be sent between Channel.isOpen and…#813hierynomus merged 2 commits intohierynomus:masterfrom
hierynomus merged 2 commits intohierynomus:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #813 +/- ##
============================================
- Coverage 64.84% 64.75% -0.09%
+ Complexity 1466 1463 -3
============================================
Files 210 210
Lines 8524 8537 +13
Branches 779 781 +2
============================================
+ Hits 5527 5528 +1
- Misses 2592 2600 +8
- Partials 405 409 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
a2a6388 to
ff30c9b
Compare
…isOpen and a Transport.write call Otherwise, a disconnect with a "packet referred to nonexistent channel" message can occur. This particularly happens when the transport.Reader thread passes an eof from the server to the ChannelInputStream, the reading library-user thread returns, and closes the channel at the same time as the transport.Reader thread receives the subsequent CHANNEL_CLOSE from the server.
hierynomus
approved these changes
Sep 17, 2022
Owner
|
Thanks for the find on how this happened! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
… a Transport.write call
Otherwise, a disconnect with a "packet referred to nonexistent channel" message can occur.
This particularly happens when the transport.Reader thread passes an eof from the server to the ChannelInputStream, the reading library-user thread returns, and closes the channel at the same time as the transport.Reader thread receives the subsequent CHANNEL_CLOSE from the server.
The issue was reproducible and debug output showed that after a CHANNEL_CLOSE from the server, sshj sporadically sent the CHANNEL_CLOSE from a Channel.close call first and afterwards the CHANNEL_EOF from AbstractChannel.gotClose.
This commit ensures,that the CHANNEL_EOF is not sent anymore if Channel.close sent out CHANNEL_CLOSE first.
The Transport.write call in DataBuffer.flush could produce a similar issue with a data packet, so it was placed within the openCloseLock, too.