Repository navigation
Free SFTP sessions and their open files at teardown - #292
Merged
Merged
Conversation
…ng them - SftpSession owns the libssh session from sftp_new on and frees it in the final task of close, on the processing thread. Before, close only dropped the object and the libssh session leaked. - Files still open then are closed there too: their deleter posted sftp_close to the finalized strand, which refused it. - Close is only reached at teardown today, the SFTP channel lives for the whole session. - The mock SFTP server counts its open SFTP sessions and can wait for a count; its CLI acknowledges promises.
- Its libssh session is null after close. lastError, the home directory fallback, requireSetInStrand, which every path method runs first, and supportsExtensionInStrand check for it: sftp_open, sftp_unlink and others dereference it. - Unreachable today, the finalized strand refuses tasks after close.
5cript
enabled auto-merge (rebase)
November 2, 2026 22:53
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.
Closing an
SftpSessionnow frees its libssh session and closes the remote files still open on it. Both leaked when a session was torn down, which is the only place SFTP sessions are closed.SftpSessionowns its libssh session asSftpSession::NativeSessionfromsftp_newon and frees it in the final task ofclose, on the processing thread.sftp_close. Before, their close was posted to the strand thatclosehad already finalized, which refused it.lastErrorreportsSSH_FX_CONNECTION_LOST, and the path methods andsupportsExtensionInStrandrefuse the closed session instead of handing libssh a null session.connectTimeoutSecondsis unset.ClosedSftpSessionEndsOnTheServerWhileTheConnectionStays,ClosingTheSftpSessionClosesItsOpenFilesOnTheServerandLastErrorOfAClosedSftpSessionIsAConnectionLoss. The mock SFTP server can report and wait for its number of open SFTP sessions.