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

test

parent 41062a0b
Loading
Loading
Loading
Loading
Loading
+11 −9
Changes for src/cluster.cpp: 11 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -266,16 +266,8 @@ namespace authdb {

        server_ = std::make_unique<paritypp::server>(scfg, store_, auth_);

        // Register peer status callback so GET_STATUS reports peer counts.
        // This callback runs on the server thread when a remote node queries us,
        // so it must NOT acquire client_mutex_ or do network I/O (deadlock risk).
        // We report config-based peer count; live probing is done via admin API.
        size_t peer_count = cfg_.peers.size() > 0 ? cfg_.peers.size() - 1 : 0;
        server_->set_peer_status_callback([peer_count]() -> std::pair<uint32_t, uint32_t> {
            return {static_cast<uint32_t>(peer_count), static_cast<uint32_t>(peer_count)};
        });

        // Setup client for talking to peers — filter out self
        size_t peer_count = 0;
        if (!cfg_.peers.empty()) {
            char hostname[256] = {};
            gethostname(hostname, sizeof(hostname));
@@ -291,6 +283,8 @@ namespace authdb {
                nodes.push_back({peer.address, peer.port});
            }

            peer_count = nodes.size();

            paritypp::client::credentials pcreds;
            if (!cfg_.client_name.empty()) {
                pcreds.client_name = cfg_.client_name;
@@ -304,6 +298,14 @@ namespace authdb {
                std::cerr << "Cluster: no remote peers after filtering self" << std::endl;
            }
        }

        // Register peer status callback so GET_STATUS reports peer counts.
        // This callback runs on the server thread when a remote node queries us,
        // so it must NOT acquire client_mutex_ or do network I/O (deadlock risk).
        // peer_count is based on actual filtered node list (after self-exclusion).
        server_->set_peer_status_callback([peer_count]() -> std::pair<uint32_t, uint32_t> {
            return {static_cast<uint32_t>(peer_count), static_cast<uint32_t>(peer_count)};
        });
    }

    void Cluster::start() {