Loading src/cluster.cpp +19 −0 Changes for src/cluster.cpp: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -389,6 +389,25 @@ namespace authdb { return false; } bool Cluster::hasSessionBySid(const uuid::uuid &session_id) { uint64_t sid_gid = sidGroupId(session_id); // Check local store std::vector<uint8_t> data; if (store_->fetch(sid_gid, 0, data)) return true; // Check peer nodes if (pclient_) { try { std::lock_guard<std::mutex> lock(client_mutex_); if (pclient_->fetch_from_peers(sid_gid, 0, data) && !data.empty()) return true; } catch (...) {} } return false; } bool Cluster::fetchSessionBySid(const uuid::uuid &session_id, uuid::uuid &sid, uuid::uuid &uid, uuid::uuid &did, std::vector<uuid::uuid> &members, Loading src/cluster.h +3 −0 Changes for src/cluster.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -138,6 +138,9 @@ namespace authdb { // Check if a session already exists in the cluster for uid+did bool hasSession(const uuid::uuid &uid, const uuid::uuid &did); // Check if a session still exists in the cluster by SID bool hasSessionBySid(const uuid::uuid &session_id); // Fetch a session from the cluster by session ID (SID) bool fetchSessionBySid(const uuid::uuid &session_id, uuid::uuid &sid, uuid::uuid &uid, uuid::uuid &did, Loading src/session.cpp +19 −1 Changes for src/session.cpp: 19 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -367,10 +367,28 @@ const authdb::SessionData *authdb::Session::getSession(uuid::uuid sessionid){ std::lock_guard<std::mutex> guard(_SessionLock); cleanupExpired(); for(SessionData *cur=_firstData; cur; cur=cur->_next){ if(cur->_sid==sessionid) if(cur->_sid==sessionid){ // Validate session still exists in cluster (may have been removed on another node) if (g_Cluster && g_Cluster->isRunning()) { if (!g_Cluster->hasSessionBySid(sessionid)) { // Session was removed on another node — purge local cache SessionData *prev = nullptr; for (SessionData *p = _firstData; p; p = p->_next) { if (p == cur) break; prev = p; } if (prev) prev->_next = cur->_next; if (cur == _firstData) _firstData = cur->_next; if (cur == _lastData) _lastData = prev; cur->_next = nullptr; delete cur; return nullptr; } } return cur; } } } // Not found locally — fetch from cluster peers by SID if (g_Cluster && g_Cluster->isRunning()) { Loading Loading
src/cluster.cpp +19 −0 Changes for src/cluster.cpp: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -389,6 +389,25 @@ namespace authdb { return false; } bool Cluster::hasSessionBySid(const uuid::uuid &session_id) { uint64_t sid_gid = sidGroupId(session_id); // Check local store std::vector<uint8_t> data; if (store_->fetch(sid_gid, 0, data)) return true; // Check peer nodes if (pclient_) { try { std::lock_guard<std::mutex> lock(client_mutex_); if (pclient_->fetch_from_peers(sid_gid, 0, data) && !data.empty()) return true; } catch (...) {} } return false; } bool Cluster::fetchSessionBySid(const uuid::uuid &session_id, uuid::uuid &sid, uuid::uuid &uid, uuid::uuid &did, std::vector<uuid::uuid> &members, Loading
src/cluster.h +3 −0 Changes for src/cluster.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -138,6 +138,9 @@ namespace authdb { // Check if a session already exists in the cluster for uid+did bool hasSession(const uuid::uuid &uid, const uuid::uuid &did); // Check if a session still exists in the cluster by SID bool hasSessionBySid(const uuid::uuid &session_id); // Fetch a session from the cluster by session ID (SID) bool fetchSessionBySid(const uuid::uuid &session_id, uuid::uuid &sid, uuid::uuid &uid, uuid::uuid &did, Loading
src/session.cpp +19 −1 Changes for src/session.cpp: 19 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -367,10 +367,28 @@ const authdb::SessionData *authdb::Session::getSession(uuid::uuid sessionid){ std::lock_guard<std::mutex> guard(_SessionLock); cleanupExpired(); for(SessionData *cur=_firstData; cur; cur=cur->_next){ if(cur->_sid==sessionid) if(cur->_sid==sessionid){ // Validate session still exists in cluster (may have been removed on another node) if (g_Cluster && g_Cluster->isRunning()) { if (!g_Cluster->hasSessionBySid(sessionid)) { // Session was removed on another node — purge local cache SessionData *prev = nullptr; for (SessionData *p = _firstData; p; p = p->_next) { if (p == cur) break; prev = p; } if (prev) prev->_next = cur->_next; if (cur == _firstData) _firstData = cur->_next; if (cur == _lastData) _lastData = prev; cur->_next = nullptr; delete cur; return nullptr; } } return cur; } } } // Not found locally — fetch from cluster peers by SID if (g_Cluster && g_Cluster->isRunning()) { Loading