From 28f69f25a001923ca880192e8b4960f7bf58496b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 22 Feb 2020 10:37:01 +0000 Subject: [PATCH] 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. --- backend/ftp/ftp.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go index 7631209da..58bd8cab6 100644 --- a/backend/ftp/ftp.go +++ b/backend/ftp/ftp.go @@ -190,7 +190,11 @@ func (f *Fs) getFtpConnection() (c *ftp.ServerConn, err error) { if 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