public function check_state($key, $ownerid) {
        if (array_key_exists($key, $this->locks)) {
            // The key is locked and we own it.
            return true;
        }
        $lockfile = $this->get_lock_file($key);
        if (file_exists($lockfile)) {
            // The key is locked and we don't own it.
            return false;
        }
        return null;
    }