Don't use timed-out child sessions for remote files

When requesting a file-like object with open or file, or implicitly by using one of the upload or download methods, ftputil uses a "child session" behind the scenes, i. e. it implicitly makes a new connection to the FTP server. If a remote file has been opened and closed before, the associated FTP session is reused. At the moment, however, this is done without checking if the connection has already timed out.

I've never heard of actual problems regarding this behavior, but it isn't correct and could lead to mysterious surprises if it's triggered.

I'm planning to remedy this by doing a getcwd call on a child session before reusing it. If that turns out to be roughly as slow as building a new session in the first place, I'll consider to get rid of the session caching altogether, thereby simplifying the code a bit.

schwa (unverified)
Assigned to
12 years ago
12 years ago
bug library

schwa (unverified) 11 years ago · edit

Fixed in revision [6e26f9dc6ad39561f10cb3858530717ffadf33d8](https://git.sr.ht/~sschwarzer/ftputil/commit/6e26f9dc6ad39561f10cb3858530717ffadf33d8 "Don't use child sessions which have timed out. Fixes #44.").

schwa (unverified) 11 years ago · edit

I decided against removing the child cache as it will most likely save a lot of time if files are requested frequently (e. g. during series of uploads or downloads). This is especially true if the files are rather small, because then the time to re-establish a server connection would be relatively large with respect to the transfer time.

Register here or Log in to comment, or comment via email.