Fix a race condition.