fix race condition in utils.lock