Fix a race condition

Signed-off-by: Paul Beeler <sparksco@gmail.com>