Commit df9264c0 authored by jan.koester's avatar jan.koester
Browse files

test

parent e04cf624
Loading
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -141,13 +141,13 @@ namespace authdb {
    }

    void ClusterBackend::pushToCluster() {
        // Legacy entry point for constructor/destructor
        // Legacy entry point for destructor
        if (!_Dirty) return;
        newRevesion();
        uint64_t dgid = domainGroupId();
        std::vector<uint8_t> buf_copy = _Buffer;
        if (pushToClusterAsync(dgid, buf_copy))
            _Dirty = false;
        pushToClusterAsync(dgid, buf_copy);
    }

    ClusterBackend::ClusterBackend(const char *domain, size_t version, const char *filepath)
@@ -220,14 +220,15 @@ namespace authdb {
        if (_Dirty) {
            newRevesion();
            uint64_t dgid = domainGroupId();
            pushToClusterAsync(dgid, _Buffer);
            if (pushToClusterAsync(dgid, _Buffer))
                _Dirty = false;
            // If push failed, _Dirty stays true so next unlock() retries
        }
    }

    void ClusterBackend::pushToClusterAsync(uint64_t dgid, const std::vector<uint8_t> &buf) {
    bool ClusterBackend::pushToClusterAsync(uint64_t dgid, const std::vector<uint8_t> &buf) {
        if (!g_Cluster || !g_Cluster->isRunning())
            return;
            return false;

        auto &client = g_Cluster->getClient();
        if (client) {
@@ -238,7 +239,7 @@ namespace authdb {
                    std::unique_lock<std::timed_mutex> lock(cmtx, std::chrono::seconds(3));
                    if (lock.owns_lock()) {
                        client->store(dgid, buf.data(), buf.size());
                        break;
                        return true;
                    }
                    if (attempt == 2) {
                        std::cerr << "ClusterBackend::pushToCluster: replication failed after retries" << std::endl;
@@ -250,6 +251,7 @@ namespace authdb {
                std::cerr << "Cluster replicate failed: " << e.what() << std::endl;
            }
        }
        return false;
    }

    void ClusterBackend::setPos(size_t pos) {
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ namespace authdb {
        uint64_t domainGroupId() const;
        void fetchFromCluster();
        void pushToCluster();
        void pushToClusterAsync(uint64_t dgid, const std::vector<uint8_t> &buf);
        bool pushToClusterAsync(uint64_t dgid, const std::vector<uint8_t> &buf);

        std::string              _Domain;
        std::vector<uint8_t>     _Buffer;