From d8a5bd054948c11c9b1a4da4fd0f5e25bb76271a Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 3 Feb 2015 12:18:30 -0800 Subject: [PATCH] dht/query: make sure to cancel all contexts. We are leaking peer queues: http://gateway.ipfs.io/ipfs/QmQxVA48CzVwwNYExUiFe56VrUBn8u368ZfchnCLoc7fSC/moriarty --- routing/dht/query.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routing/dht/query.go b/routing/dht/query.go index 293c0ddd9..7a32b45bb 100644 --- a/routing/dht/query.go +++ b/routing/dht/query.go @@ -52,6 +52,9 @@ type queryFunc func(context.Context, peer.ID) (*dhtQueryResult, error) // Run runs the query at hand. pass in a list of peers to use first. func (q *dhtQuery) Run(ctx context.Context, peers []peer.ID) (*dhtQueryResult, error) { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + runner := newQueryRunner(ctx, q) return runner.Run(peers) }