From 71ddcce4c758f7009aea26c750ef9f11e4eb1d14 Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Wed, 25 May 2016 11:34:58 +0100 Subject: [PATCH] Tie jobChan lifecycle to Begin() and End() --- transfer/basic.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transfer/basic.go b/transfer/basic.go index 3eb917fa..796cd694 100644 --- a/transfer/basic.go +++ b/transfer/basic.go @@ -34,7 +34,6 @@ type basicAdapter struct { func newBasicAdapter(d Direction) *basicAdapter { return &basicAdapter{ direction: d, - jobChan: make(chan *Transfer, 100), } } @@ -49,6 +48,7 @@ func (a *basicAdapter) Name() string { func (a *basicAdapter) Begin(cb progress.CopyCallback, completion chan TransferResult) error { a.cb = cb a.outChan = completion + a.jobChan = make(chan *Transfer, 100) numworkers := config.Config.ConcurrentTransfers() a.workerWait.Add(numworkers) @@ -64,6 +64,7 @@ func (a *basicAdapter) Add(t *Transfer) { } func (a *basicAdapter) End() { + a.jobChan.Close() // wait for all transfers to complete a.workerWait.Wait() }