Skip to content

Commit

Permalink
operations: fix goroutine leak in case of copy retry
Browse files Browse the repository at this point in the history
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()
  • Loading branch information
ankur0493 authored and ncw committed Nov 10, 2021
1 parent c968c3e commit f04520a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/accounting/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit f04520a

Please sign in to comment.