Added atomic operation to avoid data race.

Note: slave's health check is still not conflict serializable with
registered, reregistered and connected.