dht/query: make sure to cancel all contexts.
We are leaking peer queues: http://gateway.ipfs.io/ipfs/QmQxVA48CzVwwNYExUiFe56VrUBn8u368ZfchnCLoc7fSC/moriarty
Juan Batiz-Benet committed
Feb 3, 2015 at 12:18 UTC
d8a5bd054948c11c9b1a4da4fd0f5e25bb76271a
1 file changed
+3
routing/dht/query.go
+3
@@ -52,6 +52,9 @@ type queryFunc func(context.Context, peer.ID) (*dhtQueryResult, error)
52
53
// Run runs the query at hand. pass in a list of peers to use first.
54
func (q *dhtQuery) Run(ctx context.Context, peers []peer.ID) (*dhtQueryResult, error) {
55
+ ctx, cancel := context.WithCancel(ctx)
56
+ defer cancel()
57
+
58
runner := newQueryRunner(ctx, q)
59
return runner.Run(peers)
60
}