Commit b78786db authored by Jeromy Johnson's avatar Jeromy Johnson Committed by GitHub

Merge pull request #3169 from ipfs/fix/bitswap-goro-leak

bitswap: Don't clear 'active' until Connect calls are finished
parents a53c0055 1b099641
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment