fix(query): cancel the context when the query finishes

This commit is contained in:
Steven Allen 2020-02-27 17:47:15 -08:00
parent 30ba05e268
commit e6a4d6a3dd

View File

@ -125,6 +125,10 @@ func newQueryRunner(q *dhtQuery) *dhtQueryRunner {
}
func (r *dhtQueryRunner) Run(ctx context.Context, peers []peer.ID) (*dhtQueryResult, error) {
// Make sure to clean everything up when we return from this function.
ctx, cancel := context.WithCancel(ctx)
defer cancel()
r.log = logger
r.runCtx = ctx