Loading src/authdb.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -257,6 +257,15 @@ namespace authdb { rep.send(curreq,"[{\"error\":\"not initialized\"}]",29); return; } // Cluster has data but not enough peers to reconstruct — don't // show the wizard (would create conflicting admin data). if(_AdminBackend.clusterDataExists()){ libhttppp::HttpResponse rep; rep.setState(HTTP503); rep.setContentType("text/html"); rep.send(curreq,"cluster data unavailable — waiting for peers",45); return; } std::cerr << "[AUTHDB] wizard check: end=" << _AdminBackend.end() << " header=" << sizeof(authdb::AuthHeader) << std::endl; AuthBackend::Guard admlock(_AdminBackend); Loading src/backend.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,10 @@ void authdb::AuthBackend::purge(){ _Api->purge(); } bool authdb::AuthBackend::clusterDataExists() const { return _Api->clusterDataExists(); } authdb::AuthBackend::Guard::Guard(AuthBackend &backend) : _Backend(backend){ _Backend.lock(); } Loading src/backend.h +3 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ namespace authdb{ virtual void newRevesion()=0; virtual void vacuum()=0; virtual void purge(){}; virtual bool clusterDataExists() const { return false; } }; class VISIBILITY AuthBackend { Loading Loading @@ -96,6 +97,8 @@ namespace authdb{ const std::string &getDomain() const { return _Domain; } int getType() const { return _Type; } bool clusterDataExists() const; private: void lock(); void unlock(); Loading src/backends/cluster.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,9 @@ namespace authdb { } catch (const std::exception &e) { std::cerr << "ClusterBackend::fetchFromCluster: retrieve failed: " << e.what() << std::endl; // "not enough blocks" means data exists but too few peers are reachable if (std::string(e.what()).find("not enough blocks") != std::string::npos) _ClusterDataExists.store(true); } catch (...) { std::cerr << "ClusterBackend::fetchFromCluster: retrieve failed (unknown)" << std::endl; } Loading src/backends/cluster.h +3 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ namespace authdb { void vacuum(); void purge(); bool clusterDataExists() const override { return _ClusterDataExists.load(); } private: uint64_t domainGroupId() const; void fetchFromCluster(); Loading @@ -74,6 +76,7 @@ namespace authdb { std::vector<uint8_t> _Buffer; size_t _Pos; std::atomic<bool> _Dirty; std::atomic<bool> _ClusterDataExists{false}; std::chrono::steady_clock::time_point _LastPeerFetch{}; }; }; Loading
src/authdb.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -257,6 +257,15 @@ namespace authdb { rep.send(curreq,"[{\"error\":\"not initialized\"}]",29); return; } // Cluster has data but not enough peers to reconstruct — don't // show the wizard (would create conflicting admin data). if(_AdminBackend.clusterDataExists()){ libhttppp::HttpResponse rep; rep.setState(HTTP503); rep.setContentType("text/html"); rep.send(curreq,"cluster data unavailable — waiting for peers",45); return; } std::cerr << "[AUTHDB] wizard check: end=" << _AdminBackend.end() << " header=" << sizeof(authdb::AuthHeader) << std::endl; AuthBackend::Guard admlock(_AdminBackend); Loading
src/backend.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,10 @@ void authdb::AuthBackend::purge(){ _Api->purge(); } bool authdb::AuthBackend::clusterDataExists() const { return _Api->clusterDataExists(); } authdb::AuthBackend::Guard::Guard(AuthBackend &backend) : _Backend(backend){ _Backend.lock(); } Loading
src/backend.h +3 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ namespace authdb{ virtual void newRevesion()=0; virtual void vacuum()=0; virtual void purge(){}; virtual bool clusterDataExists() const { return false; } }; class VISIBILITY AuthBackend { Loading Loading @@ -96,6 +97,8 @@ namespace authdb{ const std::string &getDomain() const { return _Domain; } int getType() const { return _Type; } bool clusterDataExists() const; private: void lock(); void unlock(); Loading
src/backends/cluster.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,9 @@ namespace authdb { } catch (const std::exception &e) { std::cerr << "ClusterBackend::fetchFromCluster: retrieve failed: " << e.what() << std::endl; // "not enough blocks" means data exists but too few peers are reachable if (std::string(e.what()).find("not enough blocks") != std::string::npos) _ClusterDataExists.store(true); } catch (...) { std::cerr << "ClusterBackend::fetchFromCluster: retrieve failed (unknown)" << std::endl; } Loading
src/backends/cluster.h +3 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ namespace authdb { void vacuum(); void purge(); bool clusterDataExists() const override { return _ClusterDataExists.load(); } private: uint64_t domainGroupId() const; void fetchFromCluster(); Loading @@ -74,6 +76,7 @@ namespace authdb { std::vector<uint8_t> _Buffer; size_t _Pos; std::atomic<bool> _Dirty; std::atomic<bool> _ClusterDataExists{false}; std::chrono::steady_clock::time_point _LastPeerFetch{}; }; };