library: Fixed race of creating dht states