mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-04-24 22:32:13 +00:00
Fix deadline handling in runBootstrap subqueries
This commit is contained in:
parent
f7b176604f
commit
61d3de0d41
@ -147,9 +147,13 @@ func (dht *IpfsDHT) runBootstrap(ctx context.Context, cfg BootstrapConfig) error
|
||||
|
||||
doQuery := func(n int, target string, f func(context.Context) error) error {
|
||||
logger.Infof("Bootstrapping query (%d/%d) to %s", n, cfg.Queries, target)
|
||||
ctx, cancel := context.WithTimeout(ctx, cfg.Timeout)
|
||||
queryCtx, cancel := context.WithTimeout(ctx, cfg.Timeout)
|
||||
defer cancel()
|
||||
return f(ctx)
|
||||
err := f(queryCtx)
|
||||
if err == context.DeadlineExceeded && queryCtx.Err() == context.DeadlineExceeded && ctx.Err() == nil {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// Do all but one of the bootstrap queries as random walks.
|
||||
|
Loading…
x
Reference in New Issue
Block a user