From da5cbc194a6fa337e0ae162da5c89605f8347232 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 25 Feb 2020 11:44:29 +0000 Subject: [PATCH] ftp: fix lockup on Close failures when using concurrency limit #3984 Before this change if rclone failed to close a file download for some reason it would leak a concurrency token. When all the tokens were leaked then rclone would lock up. This fix returns the concurrency token regardless of the error status. --- backend/ftp/ftp.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go index a818dd87b..f96e66a65 100644 --- a/backend/ftp/ftp.go +++ b/backend/ftp/ftp.go @@ -788,11 +788,13 @@ func (f *ftpReadCloser) Close() error { case <-timer.C: // if timer fired assume no error but connection dead fs.Errorf(f.f, "Timeout when waiting for connection Close") + f.f.putFtpConnection(nil, nil) return nil } // if errors while reading or closing, dump the connection if err != nil || f.err != nil { _ = f.c.Quit() + f.f.putFtpConnection(nil, nil) } else { f.f.putFtpConnection(&f.c, nil) }