Skip to content

Commit 7022c62

Browse files
authored
Merge pull request #264 from libp2p/run-bootstrap-deadline-exceeded
Fix Bootstrap sub-queries
2 parents 5f67727 + 61d3de0 commit 7022c62

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

dht_bootstrap.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,14 @@ func (dht *IpfsDHT) runBootstrap(ctx context.Context, cfg BootstrapConfig) error
146146
defer logger.EventBegin(ctx, "dhtRunBootstrap").Done()
147147

148148
doQuery := func(n int, target string, f func(context.Context) error) error {
149-
logger.Debugf("Bootstrapping query (%d/%d) to %s", n, cfg.Queries, target)
150-
ctx, cancel := context.WithTimeout(ctx, cfg.Timeout)
149+
logger.Infof("Bootstrapping query (%d/%d) to %s", n, cfg.Queries, target)
150+
queryCtx, cancel := context.WithTimeout(ctx, cfg.Timeout)
151151
defer cancel()
152-
return f(ctx)
152+
err := f(queryCtx)
153+
if err == context.DeadlineExceeded && queryCtx.Err() == context.DeadlineExceeded && ctx.Err() == nil {
154+
return nil
155+
}
156+
return err
153157
}
154158

155159
// Do all but one of the bootstrap queries as random walks.

query.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (r *dhtQueryRunner) Run(ctx context.Context, peers []peer.ID) (*dhtQueryRes
168168
case <-r.proc.Closed():
169169
r.RLock()
170170
defer r.RUnlock()
171-
err = context.DeadlineExceeded
171+
err = r.runCtx.Err()
172172
}
173173

174174
if r.result != nil && r.result.success {

0 commit comments

Comments
 (0)