fix index bug the _right_ way

This commit is contained in:
Reed Allman
2019-02-23 07:54:00 -08:00
parent 525489ad56
commit 809e463d97

View File

@@ -49,10 +49,14 @@ func (p *chPlacer) PlaceCall(ctx context.Context, rp RunnerPool, call RunnerCall
var runnerPoolErr error
for {
var runners []Runner
for j := 0; len(runners) > 0 && !state.IsDone(); j++ {
for j := 0; !state.IsDone(); j++ {
// refresh each iteration (should be cached...). detect if runner list changed, and reset j if so (?)
oldRunners := runners
runners, runnerPoolErr = rp.Runners(ctx, call)
if len(runners) == 0 {
j = -1 // TODO make j cleaner, this just fixes j to 0 if runners errors
break
}
if !equal(runners, oldRunners) {
j = 0
}