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) { ...@@ -209,14 +209,18 @@ func (bs *Bitswap) providerQueryManager(ctx context.Context) {
child, cancel := context.WithTimeout(e.Ctx, providerRequestTimeout) child, cancel := context.WithTimeout(e.Ctx, providerRequestTimeout)
defer cancel() defer cancel()
providers := bs.network.FindProvidersAsync(child, e.Key, maxProvidersPerRequest) providers := bs.network.FindProvidersAsync(child, e.Key, maxProvidersPerRequest)
wg := &sync.WaitGroup{}
for p := range providers { for p := range providers {
wg.Add(1)
go func(p peer.ID) { go func(p peer.ID) {
defer wg.Done()
err := bs.network.ConnectTo(child, p) err := bs.network.ConnectTo(child, p)
if err != nil { if err != nil {
log.Debug("failed to connect to provider %s: %s", p, err) log.Debug("failed to connect to provider %s: %s", p, err)
} }
}(p) }(p)
} }
wg.Wait()
activeLk.Lock() activeLk.Lock()
kset.Remove(e.Key) kset.Remove(e.Key)
activeLk.Unlock() 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