fix data races in controller

Fix #305
Yes. I agree that sync.Cond is a better approach.