Skip to content

Commit

Permalink
Merge pull request #3169 from ipfs/fix/bitswap-goro-leak
Browse files Browse the repository at this point in the history
bitswap: Don't clear 'active' until Connect calls are finished
  • Loading branch information
whyrusleeping authored Sep 4, 2016
2 parents d6092eb + b913010 commit 6f437fb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exchange/bitswap/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,18 @@ func (bs *Bitswap) providerQueryManager(ctx context.Context) {
child, cancel := context.WithTimeout(e.Ctx, providerRequestTimeout)
defer cancel()
providers := bs.network.FindProvidersAsync(child, e.Key, maxProvidersPerRequest)
wg := &sync.WaitGroup{}
for p := range providers {
wg.Add(1)
go func(p peer.ID) {
defer wg.Done()
err := bs.network.ConnectTo(child, p)
if err != nil {
log.Debug("failed to connect to provider %s: %s", p, err)
}
}(p)
}
wg.Wait()
activeLk.Lock()
kset.Remove(e.Key)
activeLk.Unlock()
Expand Down

0 comments on commit 6f437fb

Please sign in to comment.