ftp: fix lockup when using concurrency limit on failed connections #3984

Before this change if rclone failed to make an FTP connection for some
reason it would leak a concurrency token. When all the tokens were
leaked then rclone would lock up.

The fix returns the concurrency token if creating the FTP connection
returns an error.
This commit is contained in:
Nick Craig-Wood 2020-02-22 10:37:01 +00:00
parent 07e4b9bb7f
commit 28f69f25a0

View file

@ -190,7 +190,11 @@ func (f *Fs) getFtpConnection() (c *ftp.ServerConn, err error) {
if c != nil { if c != nil {
return c, nil return c, nil
} }
return f.ftpConnection() c, err = f.ftpConnection()
if err != nil && f.opt.Concurrency > 0 {
f.tokens.Put()
}
return c, err
} }
// Return an FTP connection to the pool // Return an FTP connection to the pool