Commit 1b099641 authored by Jeromy's avatar Jeromy

bitswap: Don't clear 'active' until Connect calls are finished

License: MIT
Signed-off-by: default avatarJeromy <why@ipfs.io>
parent 3fbf157a
......@@ -201,14 +201,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()
delete(active, 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