Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sftp client close #85

Merged
merged 2 commits into from
Aug 24, 2021
Merged

Add sftp client close #85

merged 2 commits into from
Aug 24, 2021

Conversation

funkyshu
Copy link
Member

fixed #84 where sftp connections were never disconnected in a long-lived app.
Added Close to sftp backend Client interface.
Close client automatically 10 seconds (configurable in Options) after connecting unless reset by calling some server request action.

…lly 10 seconds after connecting unless reset by calling some server request action. This should solve for bug where connections remain open forever in long-lived app.
@c2fo-cibot c2fo-cibot bot added the size/L Denotes a PR that changes 100-499 lines label Aug 21, 2021
_ = fs.sftpclient.Close()
fs.sftpclient = nil
}
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ends up being the meat of the changes. This timer will disconnect after 10 seconds (default) unless a new request to the server is made (read, write, list, etc), in which case the timer will reset.
If a timer expires and closes a connection, any subsequent server request action will request a new client, reconnecting and starting new timer.
In this way, a user need not explicit call Close on a client since it will simply timeout anyway.

Copy link
Contributor

@arnab-chaudhuri-c2fo arnab-chaudhuri-c2fo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like reasonable changes based on my understanding how VFS works.

@funkyshu funkyshu merged commit 9b8d068 into master Aug 24, 2021
@funkyshu funkyshu deleted the add-sftp-client-close branch August 24, 2021 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sftp backend never closes open sftp connections
3 participants