1
mirror of https://github.com/rclone/rclone synced 2024-11-23 00:06:55 +01:00

operations: fix goroutine leak in case of copy retry

Whenever transfer.Account() is called, a new goroutine acc.averageLoop()
is started. This goroutine exits only when the channel acc.exit is closed.
acc.exit is closed when acc.Done() is called, which happens during tr.Done().

However, if tr.Reset is called during a copy low level retry, it replaces
the tr.acc, without calling acc.Done(), which results in the goroutine
mentioned above never exiting.

This commit calls acc.Done() during a tr.Reset()
This commit is contained in:
Ankur Gupta 2021-07-08 13:22:28 +05:30 committed by Nick Craig-Wood
parent c968c3e41c
commit f04520a6e3

View File

@ -132,6 +132,7 @@ func (tr *Transfer) Reset(ctx context.Context) {
ci := fs.GetConfig(ctx)
if acc != nil {
acc.Done()
if err := acc.Close(); err != nil {
fs.LogLevelPrintf(ci.StatsLogLevel, nil, "can't close account: %+v\n", err)
}