Commit 61d3de0d authored by Matt Joiner's avatar Matt Joiner

Fix deadline handling in runBootstrap subqueries

parent f7b17660
......@@ -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.
......
......@@ -168,7 +168,7 @@ func (r *dhtQueryRunner) Run(ctx context.Context, peers []peer.ID) (*dhtQueryRes
case <-r.proc.Closed():
r.RLock()
defer r.RUnlock()
err = context.DeadlineExceeded
err = r.runCtx.Err()
}
if r.result != nil && r.result.success {
......
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