~egtann/sjs

4f889ba89c41a5e4838c8d3904b33279ed831c51 — Evan Tann 1 year, 10 months ago db8c378
fix lock contention bug
2 files changed, 2 insertions(+), 4 deletions(-)

M job.go
M worker.go
M job.go => job.go +0 -1
@@ 146,7 146,6 @@ func jobTick(
	err := scheduleJobWithTimeout(workerMap, j)
	if err != nil {
		errCh.Send(errors.Wrap(err, "schedule"))
		// Keep going; we want to record the job result.
	}
}


M worker.go => worker.go +2 -3
@@ 88,10 88,9 @@ func (m *WorkerMap) AddWorker(
	}
}

// GetWorkerForJobName is not threadsafe. Guard the underlying WorkerMap with a
// lock.
func (m *WorkerMap) GetWorkerForJobName(name JobName) *Worker {
	m.mu.Lock()
	defer m.mu.Unlock()

	wg, ok := m.data[name]
	if !ok || len(wg.workers) == 0 {
		return nil