Loading src/admin.cpp +1 −1 Changes for src/admin.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -621,7 +621,7 @@ namespace authdb { // probes every node — unreachable nodes cause long waits. decltype(pclient->get_cluster_status()) health; try { std::unique_lock<std::mutex> lock(g_Cluster->getClientMutex(), std::try_to_lock); std::unique_lock<std::timed_mutex> lock(g_Cluster->getClientMutex(), std::try_to_lock); if (!lock.owns_lock()) { json_object_object_add(jobj, "status", json_object_new_string("BUSY")); json_object_object_add(jobj, "nodes_total", json_object_new_int(0)); Loading src/backend.cpp +10 −1 Changes for src/backend.cpp: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include <chrono> #include "backends/file.h" #include "backends/cluster.h" Loading Loading @@ -67,8 +69,14 @@ void authdb::AuthBackend::write(const unsigned char* dest, size_t destsize){ } void authdb::AuthBackend::lock(){ _Lock.lock(); if (!_Lock.try_lock_for(std::chrono::seconds(5))) throw AuthBackendError("backend lock timeout"); try { _Api->lock(); } catch (...) { _Lock.unlock(); throw; } } void authdb::AuthBackend::unlock(){ Loading Loading @@ -105,6 +113,7 @@ authdb::AuthBackendLock::AuthBackendLock(AuthBackend &lock) : _Lock(lock){ _Lock.lock(); } authdb::AuthBackendLock::~AuthBackendLock(){ _Lock.unlock(); } src/backend.h +1 −1 Changes for src/backend.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ namespace authdb{ AuthBackendApi *_Api; const std::string _Options; const std::string _Domain; std::mutex _Lock; std::timed_mutex _Lock; friend class AuthBackendLock; }; Loading src/backends/cluster.cpp +4 −2 Changes for src/backends/cluster.cpp: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -76,7 +76,8 @@ namespace authdb { if (client) { try { auto &cmtx = g_Cluster->getClientMutex(); std::lock_guard<std::mutex> lock(cmtx); std::unique_lock<std::timed_mutex> lock(cmtx, std::chrono::seconds(5)); if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout"); client->fetch_from_peers(dgid, 0, peer_data); } catch (const netplus::NetException &e) { std::cerr << "ClusterBackend::fetchFromCluster: fetch_from_peers failed: " Loading Loading @@ -146,7 +147,8 @@ namespace authdb { if (client) { try { auto &cmtx = g_Cluster->getClientMutex(); std::lock_guard<std::mutex> lock(cmtx); std::unique_lock<std::timed_mutex> lock(cmtx, std::chrono::seconds(5)); if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout"); client->replicate_to_peers(dgid, 0, _Buffer.data(), _Buffer.size()); } catch (const netplus::NetException &e) { std::cerr << "Cluster replicate failed: " << e.what() << std::endl; Loading src/cluster.h +2 −2 Changes for src/cluster.h: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -123,7 +123,7 @@ namespace authdb { // Accessors for backend use paritypp::block_store &getStore() { return *store_; } std::unique_ptr<paritypp::client> &getClient() { return pclient_; } std::mutex &getClientMutex() { return client_mutex_; } std::timed_mutex &getClientMutex() { return client_mutex_; } // Push a session to the cluster (after local addSession) void pushSession(const SessionData &sess); Loading Loading @@ -166,7 +166,7 @@ namespace authdb { std::unique_ptr<paritypp::server> server_; std::unique_ptr<paritypp::client> pclient_; std::mutex client_mutex_; std::timed_mutex client_mutex_; void server_loop(); }; Loading Loading
src/admin.cpp +1 −1 Changes for src/admin.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -621,7 +621,7 @@ namespace authdb { // probes every node — unreachable nodes cause long waits. decltype(pclient->get_cluster_status()) health; try { std::unique_lock<std::mutex> lock(g_Cluster->getClientMutex(), std::try_to_lock); std::unique_lock<std::timed_mutex> lock(g_Cluster->getClientMutex(), std::try_to_lock); if (!lock.owns_lock()) { json_object_object_add(jobj, "status", json_object_new_string("BUSY")); json_object_object_add(jobj, "nodes_total", json_object_new_int(0)); Loading
src/backend.cpp +10 −1 Changes for src/backend.cpp: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include <chrono> #include "backends/file.h" #include "backends/cluster.h" Loading Loading @@ -67,8 +69,14 @@ void authdb::AuthBackend::write(const unsigned char* dest, size_t destsize){ } void authdb::AuthBackend::lock(){ _Lock.lock(); if (!_Lock.try_lock_for(std::chrono::seconds(5))) throw AuthBackendError("backend lock timeout"); try { _Api->lock(); } catch (...) { _Lock.unlock(); throw; } } void authdb::AuthBackend::unlock(){ Loading Loading @@ -105,6 +113,7 @@ authdb::AuthBackendLock::AuthBackendLock(AuthBackend &lock) : _Lock(lock){ _Lock.lock(); } authdb::AuthBackendLock::~AuthBackendLock(){ _Lock.unlock(); }
src/backend.h +1 −1 Changes for src/backend.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ namespace authdb{ AuthBackendApi *_Api; const std::string _Options; const std::string _Domain; std::mutex _Lock; std::timed_mutex _Lock; friend class AuthBackendLock; }; Loading
src/backends/cluster.cpp +4 −2 Changes for src/backends/cluster.cpp: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -76,7 +76,8 @@ namespace authdb { if (client) { try { auto &cmtx = g_Cluster->getClientMutex(); std::lock_guard<std::mutex> lock(cmtx); std::unique_lock<std::timed_mutex> lock(cmtx, std::chrono::seconds(5)); if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout"); client->fetch_from_peers(dgid, 0, peer_data); } catch (const netplus::NetException &e) { std::cerr << "ClusterBackend::fetchFromCluster: fetch_from_peers failed: " Loading Loading @@ -146,7 +147,8 @@ namespace authdb { if (client) { try { auto &cmtx = g_Cluster->getClientMutex(); std::lock_guard<std::mutex> lock(cmtx); std::unique_lock<std::timed_mutex> lock(cmtx, std::chrono::seconds(5)); if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout"); client->replicate_to_peers(dgid, 0, _Buffer.data(), _Buffer.size()); } catch (const netplus::NetException &e) { std::cerr << "Cluster replicate failed: " << e.what() << std::endl; Loading
src/cluster.h +2 −2 Changes for src/cluster.h: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -123,7 +123,7 @@ namespace authdb { // Accessors for backend use paritypp::block_store &getStore() { return *store_; } std::unique_ptr<paritypp::client> &getClient() { return pclient_; } std::mutex &getClientMutex() { return client_mutex_; } std::timed_mutex &getClientMutex() { return client_mutex_; } // Push a session to the cluster (after local addSession) void pushSession(const SessionData &sess); Loading Loading @@ -166,7 +166,7 @@ namespace authdb { std::unique_ptr<paritypp::server> server_; std::unique_ptr<paritypp::client> pclient_; std::mutex client_mutex_; std::timed_mutex client_mutex_; void server_loop(); }; Loading