Commit 8a93edef authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

ratelimiter: fixing rate limiter use

Use of the ratelimiter should be conscious of the ratelimiter's
potential closing. any loops that add work to ratelimiter
should (a) only do so if the rate limiter is not closed,
or (b) prevent limiter while work is added
(i.e. use limiter.Go(addWorkHere))
parent 5846e989
...@@ -117,11 +117,10 @@ func (w *Worker) start(c Config) { ...@@ -117,11 +117,10 @@ func (w *Worker) start(c Config) {
} }
}) })
// reads from |workerChan| until process closes // reads from |workerChan| until w.process closes
w.process.Go(func(proc process.Process) { limiter := ratelimit.NewRateLimiter(w.process, c.NumWorkers)
limiter.Go(func(proc process.Process) {
ctx := waitable.Context(proc) // shut down in-progress HasBlock when time to die ctx := waitable.Context(proc) // shut down in-progress HasBlock when time to die
limiter := ratelimit.NewRateLimiter(process.Background(), c.NumWorkers)
defer limiter.Close()
for { for {
select { select {
case <-proc.Closing(): case <-proc.Closing():
......
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